(**
This file is part of the Coquelicot formalization of real
analysis in Coq: http://coquelicot.saclay.inria.fr/

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Copyright (C) 2011-2015 Sylvie Boldo
#<br />#
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Copyright (C) 2011-2015 Catherine Lelay
#<br />#
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Copyright (C) 2011-2015 Guillaume Melquiond

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
COPYING file for more details.
*)

Require Import Reals Psatz.
Require Import mathcomp.ssreflect.ssreflect mathcomp.ssreflect.ssrbool mathcomp.ssreflect.eqtype mathcomp.ssreflect.seq.
Require Import Markov Rcomplements Rbar Lub Lim_seq SF_seq.
Require Import Continuity Hierarchy.

(** This file contains the definition and properties of the Riemann
integral, defined on a normed module on [R]. For real functions, a
total function [RInt] is available. *)

Section is_RInt.

(** * Definition of Riemann integral *)

Context {V : NormedModule R_AbsRing}.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Definition is_RInt (f : R -> V) (a b : R) (If : V) :=
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  filterlim (fun ptd => scal (sign (b-a)) (Riemann_sum f ptd)) (Riemann_fine a b) (locally If).

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Definition ex_RInt (f : R -> V) (a b : R) :=
  exists If : V, is_RInt f a b If.

(** ** Usual properties *)
(** The integral between a and a is null *)

Lemma is_RInt_point :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a : R),
  is_RInt f a a zero.
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a : R), ex_RInt f a a *)
intros f a.
(* Goal: is_RInt f a a (@zero (NormedModule.AbelianGroup R_AbsRing V)) *)
apply filterlim_locally.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
move => eps ; exists (mkposreal _ Rlt_0_1) => ptd _ [Hptd [Hh Hl]].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Riemann_sum_zero.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite scal_zero_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
by apply ball_center.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
by apply ptd_sort.
move: Hl Hh ; rewrite /Rmin /Rmax ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
by case: Rle_dec (Rle_refl a) => _ _ ->.
Qed.

Lemma ex_RInt_point :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) a,
  ex_RInt f a a.
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a : R), ex_RInt f a a *)
intros f a.
(* Goal: ex_RInt f a a *)
exists zero ; by apply is_RInt_point.
Qed.

(** Swapping bounds *)

Lemma is_RInt_swap :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a b : R) (If : V),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f b a If -> is_RInt f a b (opp If).
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (If : NormedModule.sort R_AbsRing V) (_ : is_RInt f b a If), is_RInt f a b (@opp (NormedModule.AbelianGroup R_AbsRing V) If) *)
  unfold is_RInt.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (If : NormedModule.sort R_AbsRing V) (_ : @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus a b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (Riemann_fine b a) (@locally (NormedModule.UniformSpace R_AbsRing V) If)), @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@opp (NormedModule.AbelianGroup R_AbsRing V) If)) *)
  intros f a b If HIf.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -scal_opp_one /=.
  apply filterlim_ext with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (fun ptd => scal (opp (one : R)) (scal (sign (a - b)) (Riemann_sum f ptd))).
(* Goal: forall x : @SF_seq R, @eq (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (@one R_Ring)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus a b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x)) *)
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (@one R_Ring)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus a b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing V) (@opp (Ring.AbelianGroup (AbsRing.Ring R_AbsRing)) (@one (AbsRing.Ring R_AbsRing))) If)) *)
  intros x.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite scal_assoc.
(* Goal: @eq (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@mult R_Ring (@opp R_AbelianGroup (@one R_Ring)) (sign (Rminus a b))) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x)) *)
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (@one R_Ring)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus a b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing V) (@opp (Ring.AbelianGroup (AbsRing.Ring R_AbsRing)) (@one (AbsRing.Ring R_AbsRing))) If)) *)
  apply (f_equal (fun s => scal s _)).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /mult /opp /one /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite -(Ropp_minus_distr' b a) sign_opp /= Ropp_mult_distr_l_reverse Rmult_1_l.
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (@one R_Ring)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus a b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing V) (@opp (Ring.AbelianGroup (AbsRing.Ring R_AbsRing)) (@one (AbsRing.Ring R_AbsRing))) If)) *)
  unfold Riemann_fine.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rmin_comm Rmax_comm.
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (@one R_Ring)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus a b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (@within (@SF_seq R) (fun ptd : @SF_seq R => and (pointed_subdiv ptd) (and (@eq R (@SF_h R ptd) (Rmin b a)) (@eq R (@last R (@SF_h R ptd) (@SF_lx R ptd)) (Rmax b a)))) (@locally_dist (@SF_seq R) (fun ptd : @SF_seq R => seq_step (@SF_lx R ptd)))) (@locally (NormedModule.UniformSpace R_AbsRing V) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing V) (@opp (Ring.AbelianGroup (AbsRing.Ring R_AbsRing)) (@one (AbsRing.Ring R_AbsRing))) If)) *)
  apply filterlim_comp with (1 := HIf).
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: filterlim_scal_r.
Qed.

Lemma ex_RInt_swap :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a b : R),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b -> ex_RInt f b a.
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (_ : ex_RInt f a b), ex_RInt f b a *)
  intros f a b.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => If HIf.
(* Goal: ex_RInt (fun x : R => @opp (NormedModule.AbelianGroup R_AbsRing V) (f x)) a b *)
  exists (opp If).
(* Goal: is_RInt f b a (@opp (NormedModule.AbelianGroup R_AbsRing V) If) *)
  now apply is_RInt_swap.
Qed.

(** Integrable implies bounded *)

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma ex_RInt_ub (f : R -> V) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b -> exists M : R, forall t : R,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    Rmin a b <= t <= Rmax a b -> norm (f t) <= M.
Proof.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  wlog: a b / (a < b) => [ Hw | Hab ] Hex.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Rle_lt_dec a b) => Hab.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Hab => Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.
    rewrite /Rmin /Rmax ; case: Rle_dec (Req_le _ _ Hab) => // _ _ ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite -Hab.
    exists (norm (f a)) => t Ht ; replace t with a.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: Rle_refl.
    apply Rle_antisym ; by case: Ht.
    rewrite Rmin_comm Rmax_comm ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply ex_RInt_swap in Hex ; by apply Hw.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /Rmin /Rmax ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _.

(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Hex => If Hex.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  generalize (proj1 (filterlim_locally_ball_norm _ If) Hex) => {Hex} /= Hex.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Hex (mkposreal _ Rlt_0_1)) => {Hex} alpha Hex.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have Hn : 0 <= ((b-a)/alpha).
    apply Rdiv_le_0_compat.
    apply -> Rminus_le_0 ; apply Rlt_le, Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply alpha.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set n := (nfloor _ Hn).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  set ptd := fun (g : R -> R -> R) =>
    SF_seq_f2 g (unif_part a b n).

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  assert (forall g, pointed_subdiv (ptd g) ->
    norm (minus (Riemann_sum f (ptd g)) If) < 1).
    move => g Hg ; replace (Riemann_sum f (ptd g))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      with (scal (sign (b - a)) (Riemann_sum f (ptd g))).
  apply Hex.
  apply Rle_lt_trans with ((b-a)/(INR n + 1)).
  clearbody n ; rewrite SF_lx_f2.
  replace (head 0 (unif_part a b n) :: behead (unif_part a b n))
    with (unif_part a b n) by auto.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  suff : forall i, (S i < size (unif_part a b n))%nat ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    nth 0 (unif_part a b n) (S i) - nth 0 (unif_part a b n) i = (b-a)/(INR n + 1).
  elim: (unif_part a b n) => [ /= _ | x0].
  apply Rdiv_le_0_compat ; [ by apply Rlt_le, Rgt_minus | by intuition ].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => /= [ | x1 s] IH Hnth.
  apply Rdiv_le_0_compat ; [ by apply Rlt_le, Rgt_minus | by intuition ].
  replace (seq_step _)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    with (Rmax (Rabs (x1 - x0)) (seq_step (x1 :: s))) by auto.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply Rmax_case_strong => _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (Hnth O (lt_n_S _ _ (lt_O_Sn _))) Rabs_right.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Rle_refl.
  apply Rle_ge, Rdiv_le_0_compat ; [ by apply Rlt_le, Rgt_minus | by intuition ].
  apply IH => i Hi ; exact: (Hnth (S i) (lt_n_S _ _ Hi)).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite size_mkseq => i Hi.
  rewrite ?nth_mkseq ?S_INR ; try apply SSR_leq.
  field ; apply Rgt_not_eq ; by intuition.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: lt_le_weak.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_O_Sn.
  apply Rlt_div_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply INRp1_pos.
  rewrite Rmult_comm ; apply Rlt_div_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply alpha.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /n /nfloor ; case: nfloor_ex => /= n' Hn'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hn'.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply Hg.
  rewrite -> Rmin_left, Rmax_right by now apply Rlt_le.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply head_unif_part.
  clearbody n ; rewrite /Rmax -nth_last SF_lx_f2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite size_mkseq nth_mkseq ?S_INR //.
  field ; apply Rgt_not_eq ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_O_Sn.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  rewrite -> sign_eq_1 by exact: Rlt_Rminus.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: scal_one.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: H => {Hex} Hex.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  assert (exists M, forall g : R -> R -> R,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    pointed_subdiv (ptd g) -> norm (Riemann_sum f (ptd g)) <= M).
    exists (norm If + 1) ; move => g Hg.
    replace (Riemann_sum f (ptd g))
      with (plus (minus (Riemann_sum f (ptd g)) If) If).
    apply Rle_trans with (norm (minus (Riemann_sum f (ptd g)) If) + norm If).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by generalize (norm_triangle (minus (Riemann_sum f (ptd g)) If) If).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rplus_comm.
    apply Rplus_le_compat_l.
    apply Rlt_le.
    by apply Hex.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by rewrite /minus -plus_assoc plus_opp_l plus_zero_r.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  clearbody n ; move: H => {Hex} Hex.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  assert (forall i, (S i < size (unif_part a b n))%nat ->
    exists M, forall t,
      nth 0 (unif_part a b n) i <= t <= nth 0 (unif_part a b n) (S i)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      -> norm (f t) <= M).
    move => i ; revert ptd Hex.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    have : sorted Rlt (unif_part a b n).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
      apply sorted_nth => j Hj x0.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite size_mkseq /= in Hj.
      rewrite ?nth_mkseq ?S_INR /= ; try apply SSR_leq.
      apply Rminus_gt ; field_simplify.
      rewrite Rplus_comm Rdiv_1 ; apply Rdiv_lt_0_compat.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
      exact: Rgt_minus.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      apply Rgt_not_eq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by intuition.
    elim: (unif_part a b n) i => [ /= i _ _ Hi | x0].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case => [ /= _ i _ _ Hi | x1 s IH].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_S_n, lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case => [ | i] Hlt /= Hex Hi.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    assert (exists M, forall t g, x0 <= t <= x1 ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      pointed_subdiv (SF_seq_f2 g [:: x1 & s]) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      norm (plus (scal (x1 - x0) (f t)) (Riemann_sum f (SF_seq_f2 g [:: x1 & s]))) <= M).
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Hex) => M Hex'.
    exists M ;
    move => t g Ht Hg.
    set g0 := fun x y =>
      match Req_EM_T x x0 with
        | left _ =>  t
        | right _ => g x y
      end.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    replace (plus (scal (x1 - x0) (f t)) (Riemann_sum f (SF_seq_f2 g (x1 :: s))))
      with (Riemann_sum f (SF_seq_f2 g0 [:: x0, x1 & s])).
    apply Hex'.
    case => [ | j] Hj ; rewrite SF_size_f2 /= in Hj ;
    rewrite SF_ly_f2 SF_lx_f2 /=.
    2: apply lt_O_Sn.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /g0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by case: Req_EM_T (refl_equal x0).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite (nth_pairmap 0).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /g0.
    suff : (nth 0 (x1 :: s) j) <> x0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Req_EM_T => // _ _.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (Hg j).
    rewrite SF_size_f2 ; rewrite SF_ly_f2 SF_lx_f2 /=.
    2: apply lt_O_Sn.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite (nth_pairmap 0).
    move => Hg' ; by apply Hg', lt_S_n.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; by intuition.
(* Goal: not (@eq R (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) (IZR Z0)) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    apply Rgt_not_eq.
    apply lt_S_n in Hj.
    elim: j Hj => {IH} [ | j IH] Hj.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hlt.
    apply Rlt_trans with (nth 0 (x1 :: s) j).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply IH ; by intuition.
    apply (sorted_nth Rlt).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hlt.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_0_Sn.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite SF_cons_f2 /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Riemann_sum_cons /=.
    apply f_equal2.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    apply f_equal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /g0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by case: Req_EM_T (refl_equal x0).
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: s Hlt {IH Hex Hex' Hi Hg} => [ | x2 s] Hlt.
    reflexivity.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite !(SF_cons_f2 _ x1) /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite !Riemann_sum_cons /=.
    apply f_equal2.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    apply f_equal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /g0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by case: Req_EM_T (Rgt_not_eq _ _ (proj1 Hlt)).
    elim: s x2 Hlt => [ | x3 s IH] x2 Hlt.
    reflexivity.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite !(SF_cons_f2 _ x2) /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite !Riemann_sum_cons /=.
    apply f_equal2.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    apply f_equal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /g0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by case: Req_EM_T (Rgt_not_eq _ _ (Rlt_trans _ _ _ (proj1 Hlt) (proj1 (proj2 Hlt)))).
    apply IH.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hlt.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply Rlt_trans with x2 ; by apply Hlt.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hlt.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_O_Sn.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: H => {Hex} Hex.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Hex) => M Hex'.
  exists ((M + norm (Riemann_sum f (SF_seq_f2 (fun x y => x) (x1 :: s)))) / abs (x1 - x0)).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => t Ht.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have Hg : pointed_subdiv (SF_seq_f2 (fun x y : R => x) (x1 :: s)).
    move => j ; rewrite SF_size_f2 SF_lx_f2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    rewrite SF_ly_f2 /= => Hj.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite (nth_pairmap 0).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
    apply Rle_refl.
    apply Rlt_le, (sorted_nth Rlt (x1::s)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hlt.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; by intuition.
    apply lt_O_Sn.
  specialize (Hex' _ _ Ht Hg).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -(scal_one (f t)).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /one /= -(Rinv_l (x1 - x0)).
  2: by apply Rgt_not_eq, Rgt_minus, Hlt.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -scal_assoc.
  eapply Rle_trans ; try apply @norm_scal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rmult_comm.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /abs /= Rabs_Rinv.
  2: by apply Rgt_not_eq, Rgt_minus, Hlt.
  apply Rmult_le_compat_r.
  apply Rlt_le, Rinv_0_lt_compat.
  apply Rabs_pos_lt, Rgt_not_eq.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rgt_minus, Hlt.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set v:= scal _ _.
  replace v
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    with (minus (plus (scal (x1 - x0) (f t))
            (Riemann_sum f (SF_seq_f2 (fun x _ : R => x) (x1 :: s))))
            (Riemann_sum f (SF_seq_f2 (fun x _ : R => x) (x1 :: s)))).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /minus.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rle_trans with (norm (plus (scal (x1 - x0) (f t))
        (Riemann_sum f (SF_seq_f2 (fun x _ : R => x) (x1 :: s))))
        + norm (opp (Riemann_sum f (SF_seq_f2 (fun x _ : R => x) (x1 :: s))))).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  by generalize (norm_triangle (plus (scal (x1 - x0) (f t))
        (Riemann_sum f (SF_seq_f2 (fun x _ : R => x) (x1 :: s))))
     (opp (Riemann_sum f (SF_seq_f2 (fun x _ : R => x) (x1 :: s))))).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite norm_opp.
  apply Rplus_le_compat_r.
  apply Hex'.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /minus -plus_assoc plus_opp_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply plus_zero_r.
  apply IH.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hlt.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Hex => M Hex.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  exists ((M + norm (scal (x1 - x0) (f x0)))) => g Hg.
  set g0 := fun x y =>
      match Req_EM_T x x0 with
        | left _ => x0
        | right _ => g x y
      end.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have Hg0 : pointed_subdiv (SF_seq_f2 g0 (x0::x1 :: s)).
    move => j ; rewrite SF_size_f2 SF_lx_f2.
    2: apply lt_O_Sn.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    rewrite SF_ly_f2 => Hj.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite nth_behead (nth_pairmap 0) /=.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: j Hj => /= [ | j ] Hj.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /g0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Req_EM_T (refl_equal x0) => // _ _.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: Rle_refl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rlt_le, Hlt.
    suff : (nth 0 (x1 :: s) j) <> x0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    rewrite /g0 ; case: Req_EM_T => // _ _.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (Hg j).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite SF_size_f2 SF_lx_f2.
    2: apply lt_O_Sn.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    rewrite SF_ly_f2 /= => {Hg} Hg.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    move: (Hg (lt_S_n _ _ Hj)) ; rewrite (nth_pairmap 0).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; by intuition.
(* Goal: not (@eq R (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) (IZR Z0)) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    apply Rgt_not_eq.
    elim: j Hj => {IH} /= [ | j IH] Hj.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hlt.
    apply Rlt_trans with (nth 0 (x1 :: s) j).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply IH ; by intuition.
    apply (sorted_nth Rlt (x1::s)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hlt.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; by intuition.
    replace (Riemann_sum f (SF_seq_f2 g (x1 :: s)))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      with (minus (Riemann_sum f (SF_seq_f2 g0 (x0::x1::s))) (scal (x1 - x0) (f x0))).
    apply Rle_trans with (norm (Riemann_sum f (SF_seq_f2 g0 [:: x0, x1 & s]))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
     + norm (opp (scal (x1 - x0) (f x0)))).
    by generalize (norm_triangle (Riemann_sum f (SF_seq_f2 g0 [:: x0, x1 & s]))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      (opp (scal (x1 - x0) (f x0)))).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite norm_opp.
    apply Rplus_le_compat_r, (Hex _ Hg0).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /minus plus_comm SF_cons_f2 /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Riemann_sum_cons /= plus_assoc.
    replace (Riemann_sum f (SF_seq_f2 g0 (x1 :: s))) with
      (Riemann_sum f (SF_seq_f2 g (x1 :: s))).
    replace (g0 x0 x1) with x0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by rewrite plus_opp_l plus_zero_l.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    rewrite /g0 ; case: Req_EM_T (refl_equal x0) => //.
    elim: s x1 Hlt {IH Hex Hg Hg0 Hi} => [ | x2 s IH] x1 Hlt.
    reflexivity.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite !(SF_cons_f2 _ x1) /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite !Riemann_sum_cons /=.
    apply f_equal2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    rewrite /g0 ; by case: Req_EM_T (Rgt_not_eq _ _ (proj1 Hlt)).
    apply IH.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply Rlt_trans with x1 ; by apply Hlt.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hlt.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: lt_O_Sn.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: lt_O_Sn.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: lt_O_Sn.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: lt_S_n.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move:H => {Hex} Hex.
  replace b with (last 0 (unif_part a b n)).
  pattern a at 1 ; replace a with (head 0 (unif_part a b n)).
  elim: (unif_part a b n) Hex => /= [ | x0].
  exists (norm (f 0)) => t Ht ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  rewrite (Rle_antisym t 0) ; by intuition.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => /= [ | x1 s] IH Hex.
  exists (norm (f x0)) => t Ht ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  rewrite (Rle_antisym t x0) ; by intuition.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Hex _ (lt_n_S _ _ (lt_O_Sn _))) => /= M0 H0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: IH => [ | M IH].
  move => i Hi ; case: (Hex _ (lt_n_S _ _ Hi)) => {Hex} /= M Hex.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by exists M.
  exists (Rmax M0 M) => t Ht ;
  case: (Rlt_le_dec t x1) => Ht0.
  apply Rle_trans with (2 := RmaxLess1 _ _) ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply H0 ; by intuition.
  apply Rle_trans with (2 := RmaxLess2 _ _) ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply IH ; by intuition.
  apply head_unif_part.
  apply last_unif_part.
Qed.

(** Extensionality *)

Lemma is_RInt_ext :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f g : R -> V) (a b : R) (l : V),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x, Rmin a b < x < Rmax a b -> f x = g x) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b l -> is_RInt g a b l.
Proof.
  intros f g a b.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  wlog: a b / (a < b) => [Hw | Hab] l Heq Hf.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Rle_lt_dec a b) => Hab.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Hab => Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite -Hab in Hf |- *.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    move: Hf ; apply filterlim_ext => x.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by rewrite Rminus_eq_0 sign_0 !scal_zero_l.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite -(opp_opp l).
    apply is_RInt_swap.
    apply Hw.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    by rewrite Rmin_comm Rmax_comm.
    by apply is_RInt_swap.
(* Goal: @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) *)
    move: Heq ; rewrite /Rmin /Rmax ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _ Heq.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply filterlim_locally_ball_norm => eps.
  destruct (proj1 (filterlim_locally_ball_norm _ _) Hf (pos_div_2 eps)) as [d Hd].
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set dx := fun x => pos_div_2 (pos_div_2 eps) / Rmax 1 (norm (minus (g x) (f x))).
  assert (forall x, 0 < dx x).
(* Goal: forall x : @SF_seq R, @eq (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (@one R_Ring)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus a b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x)) *)
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (@one R_Ring)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus a b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing V) (@opp (Ring.AbelianGroup (AbsRing.Ring R_AbsRing)) (@one (AbsRing.Ring R_AbsRing))) If)) *)
    intros x.
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    apply Rdiv_lt_0_compat.
    apply is_pos_div_2.
    eapply Rlt_le_trans, Rmax_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rlt_0_1.
  assert (Hdelta : 0 < Rmin d (Rmin (dx a) (dx b))).
    repeat apply Rmin_case => //.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply d.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  exists (mkposreal _ Hdelta) => /= y Hstep [Hptd [Hya Hyb]].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (double_var eps).
  eapply ball_norm_triangle.
  apply Hd.
  eapply Rlt_le_trans, Rmin_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hstep.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  split => //.

(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  have: (seq_step (SF_lx y) < (Rmin (dx a) (dx b))) => [ | {Hstep} Hstep].
    eapply Rlt_le_trans, Rmin_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hstep.
  clear d Hd Hdelta Hf.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  rewrite -> sign_eq_1 by exact: Rlt_Rminus.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !scal_one.
  move: Hya Hyb ;
  rewrite /Rmin /Rmax ;
  case: Rle_dec (Rlt_le _ _ Hab) => // _ _ Hya Hyb.
  move: Hab Heq Hstep ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Hyb => {b Hyb} ;
  set b := last (SF_h y) (unzip1 (SF_t y)) ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Hya => {a Hya} ;
  set a := SF_h y => Hab Heq Hstep.
(* *)
  revert a b Hab Heq Hptd Hstep ;
  apply SF_cons_ind with (s := y)
  => {y} [x0 | x0 y IH] a b Hab Heq Hptd Hstep.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !Riemann_sum_zero //.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply (ball_norm_center _ (pos_div_2 eps)).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !Riemann_sum_cons.
  assert (Hx0 := proj1 (ptd_sort _ Hptd)).
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Hx0 => /= Hx0.
Focus 2. (* fst x0 = SF_h y *)
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Hx0 Rminus_eq_0 !scal_zero_l !plus_zero_l.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: IH.
  move: Hab ; unfold a, b ; simpl ; by rewrite Hx0.
(* Goal: forall (x : R) (_ : and (Rlt a x) (Rlt x b)), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  intros x Hx.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  apply Heq ; split.
  unfold a ; simpl ; rewrite Hx0 ; apply Hx.
  unfold b ; simpl ; apply Hx.
  eapply ptd_cons, Hptd.
  move: Hstep ; unfold a, b ; simpl ; rewrite Hx0.
  apply Rle_lt_trans, Rmax_r.
(* fst x0 < SF_h y *)
  clear IH.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (double_var (eps / 2)).
  eapply Rle_lt_trans, Rplus_lt_compat.
  eapply Rle_trans, norm_triangle.
  apply Req_le, f_equal.
  replace (@minus V _ _)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    with (plus (scal (SF_h y - fst x0) (minus (g (snd x0)) (f (snd x0))))
               (minus (Riemann_sum g y) (Riemann_sum f y))).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /minus opp_plus scal_distr_l -scal_opp_r -!plus_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
  rewrite !plus_assoc ; apply f_equal2 => //.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply plus_comm.
  eapply Rle_lt_trans.
  apply @norm_scal.
  assert (Ha := proj1 (Hptd O (lt_O_Sn _))).
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Ha => /= Ha.
  assert (Hb : snd x0 <= b).
    eapply Rle_trans, sorted_last.
    2: apply ptd_sort.
    2: eapply ptd_cons, Hptd.
    2: apply lt_O_Sn.
    simpl.
    apply (Hptd O), lt_O_Sn.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Hb => //= Hb.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Heq.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite minus_eq_zero norm_zero Rmult_0_r.
  apply (is_pos_div_2 (pos_div_2 eps)).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  by split.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Hb.
  eapply Rle_lt_trans.
  apply Rmult_le_compat_l, (Rmax_r 1).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply abs_ge_0.
  apply Rlt_div_r.
  eapply Rlt_le_trans, Rmax_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_0_1.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -/(dx b).
  eapply Rlt_le_trans, Rmin_r.
  eapply Rle_lt_trans, Hstep.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rmax_l.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -Ha.
  eapply Rle_lt_trans.
  apply Rmult_le_compat_l, (Rmax_r 1).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply abs_ge_0.
  apply Rlt_div_r.
  eapply Rlt_le_trans, Rmax_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_0_1.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -/(dx a).
  eapply Rlt_le_trans, Rmin_l.
  eapply Rle_lt_trans, Hstep.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rmax_l.

(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  have: (forall x : R, SF_h y <= x < b -> f x = g x) => [ | {Heq} Heq].
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
    intros.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    apply Heq ; split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by eapply Rlt_le_trans, H0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply H0.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  have: (seq_step (SF_lx y) < (dx b)) => [ | {Hstep} Hstep].
    eapply Rlt_le_trans, Rmin_r.
    eapply Rle_lt_trans, Hstep.
    apply Rmax_r.
  simpl in b.
  apply ptd_cons in Hptd.
  clear a Hab x0 Hx0.
  revert b Heq Hptd Hstep ;
  apply SF_cons_ind with (s := y)
  => {y} [x0 | x0 y IH] b Heq Hptd Hstep.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !Riemann_sum_zero // minus_eq_zero norm_zero.
  apply (is_pos_div_2 (pos_div_2 _)).

(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !Riemann_sum_cons.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (minus (plus (scal (SF_h y - fst x0) (g (snd x0))) (Riemann_sum g y))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (plus (scal (SF_h y - fst x0) (f (snd x0))) (Riemann_sum f y)))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    with (plus (scal (SF_h y - fst x0) (minus (g (snd x0)) (f (snd x0))))
               (minus (Riemann_sum g y) (Riemann_sum f y))).
  eapply Rle_lt_trans.
(* Goal: Rle (@norm R_AbsRing V (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply @norm_triangle.
  assert (SF_h y <= b).
    eapply Rle_trans, sorted_last.
    2: apply ptd_sort ; eapply ptd_cons, Hptd.
    2: apply lt_O_Sn.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
    simpl ; by apply Rle_refl.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: H0 => Hb.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Heq.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite minus_eq_zero scal_zero_r norm_zero Rplus_0_l.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
  apply IH ; intros.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  apply Heq ; split.
  eapply Rle_trans, H0.
  eapply Rle_trans ; by apply (Hptd O (lt_O_Sn _)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply H0.
  eapply ptd_cons, Hptd.
  eapply Rle_lt_trans, Hstep.
  by apply Rmax_r.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply (Hptd O (lt_O_Sn _)).
  eapply Rle_lt_trans, Hb.
  apply (Hptd O (lt_O_Sn _)).
  clear IH.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Hb !Riemann_sum_zero //.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite minus_eq_zero norm_zero Rplus_0_r.
  eapply Rle_lt_trans.
  apply @norm_scal.
  assert (snd x0 <= b).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite -Hb.
    apply (Hptd O (lt_O_Sn _)).
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: H0 => Hb'.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Heq.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite minus_eq_zero norm_zero Rmult_0_r.
  apply (is_pos_div_2 (pos_div_2 _)).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply (Hptd O (lt_O_Sn _)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Hb'.
  eapply Rle_lt_trans.
(* Goal: Rle (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing R_NormedModule) f' ptd)) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  apply Rmult_le_compat_l.
  apply abs_ge_0.
  apply (Rmax_r 1).
  apply Rlt_div_r.
  eapply Rlt_le_trans, Rmax_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_0_1.
  eapply Rle_lt_trans, Hstep.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -Hb.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rmax_l.
  apply ptd_sort ; eapply ptd_cons, Hptd.
  apply ptd_sort ; eapply ptd_cons, Hptd.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /minus opp_plus scal_distr_l -scal_opp_r -!plus_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !plus_assoc.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply f_equal2 => //.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply plus_comm.
Qed.

Lemma ex_RInt_ext :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f g : R -> V) (a b : R),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x, Rmin a b < x < Rmax a b -> f x = g x) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b -> ex_RInt g a b.
Proof.
(* Goal: forall (f g : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (_ : forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing V) (f x) (g x)) (_ : ex_RInt f a b), ex_RInt g a b *)
intros f g a b Heq [If Hex].
(* Goal: ex_RInt g a b *)
exists If.
(* Goal: is_RInt g a b If *)
revert Hex.
(* Goal: forall _ : is_RInt f a b If, is_RInt g a b If *)
now apply is_RInt_ext.
Qed.

(** ** Constant functions *)

Lemma is_RInt_const :
  forall (a b : R) (v : V),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt (fun _ => v) a b (scal (b - a) v).
Proof.
(* Goal: forall (a b : R) (v : NormedModule.sort R_AbsRing V), ex_RInt (fun _ : R => v) a b *)
intros a b v.
apply filterlim_within_ext with (fun _ => scal (b - a) v).
2: apply filterlim_const.
intros ptd [_ [Hhead Hlast]].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Riemann_sum_const.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Hlast Hhead.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite scal_assoc.
apply (f_equal (fun x => scal x v)).
apply sym_eq, sign_min_max.
Qed.

Lemma ex_RInt_const :
  forall (a b : R) (v : V),
  ex_RInt (fun _ => v) a b.
Proof.
(* Goal: forall (a b : R) (v : NormedModule.sort R_AbsRing V), ex_RInt (fun _ : R => v) a b *)
intros a b v.
(* Goal: ex_RInt (fun _ : R => v) a b *)
exists (scal (b - a) v).
(* Goal: is_RInt (fun _ : R => v) a b (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (Rminus b a) v) *)
apply is_RInt_const.
Qed.

(** ** Composition *)

Lemma is_RInt_comp_opp :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a b : R) (l : V),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f (-a) (-b) l ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt (fun y => opp (f (- y))) a b l.
Proof.
intros f a b l Hf.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
apply filterlim_locally => eps.
generalize (proj1 (filterlim_locally _ _) Hf eps) ; clear Hf ; intros [delta Hf].
exists delta.
intros ptd Hstep [Hptd [Hh Hl]].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Riemann_sum_opp.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite scal_opp_r -scal_opp_l /opp /= -sign_opp.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Ropp_plus_distr.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  set ptd' := (mkSF_seq (-SF_h ptd)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (seq.map (fun X => (- fst X,- snd X)) (SF_t ptd))).
replace (Riemann_sum (fun x => f (-x)) ptd) with (Riemann_sum f (SF_rev ptd')).
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have H : SF_size ptd = SF_size ptd'.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /SF_size /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by rewrite size_map.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  apply Hf.
  clear H ;
  revert ptd' Hstep ;
  apply SF_cons_dec with (s := ptd) => [ x0  s' Hs'| h0 s] ;
  rewrite /seq_step.
  apply cond_pos.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set s' := {| SF_h := - SF_h s; SF_t := [seq (- fst X, - snd X) | X <- SF_t s] |}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (SF_rev_cons (-fst h0,-snd h0) s').
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_lx_rcons.
  rewrite behead_rcons ; [ | rewrite SF_size_lx ; by apply lt_O_Sn ].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite head_rcons.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_lx_cons.
  revert h0 s' ;
  move: {1 3}(0) ;
  apply SF_cons_ind with (s := s) => {s} [ x1 | h1 s IH] x0 h0 s' Hs' ;
  simpl in Hs'.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /= -Ropp_minus_distr' /Rminus -Ropp_plus_distr Ropp_involutive.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hs'.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set s'' := {| SF_h := - SF_h s; SF_t := [seq (- fst X, - snd X) | X <- SF_t s] |}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (SF_rev_cons (-fst h1,-snd h1) s'').
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_lx_rcons.
  rewrite behead_rcons ; [ | rewrite SF_size_lx ; by apply lt_O_Sn ].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite head_rcons.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite pairmap_rcons.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite foldr_rcons.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: IH => /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (Rmax (Rabs (SF_h s - fst h1))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (foldr Rmax (Rmax (Rabs (- fst h0 - - fst h1)) x0)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
     (pairmap (fun x y : R => Rabs (y - x)) (SF_h s) (unzip1 (SF_t s)))))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    with (Rmax (Rabs (fst h1 - fst h0))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
        (Rmax (Rabs (SF_h s - fst h1))
           (foldr Rmax x0
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
              (pairmap (fun x y : R => Rabs (y - x)) (SF_h s)
                 (unzip1 (SF_t s)))))).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rmax_assoc (Rmax_comm (Rabs _)) -Rmax_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -(Ropp_minus_distr' (-fst h0)) /Rminus -Ropp_plus_distr Ropp_involutive.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  elim: (pairmap (fun x y : R => Rabs (y + - x)) (SF_h s) (unzip1 (SF_t s)))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    x0 {Hs'} (Rabs (fst h1 + - fst h0)) => [ | x2 t IH] x0 x1 /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rmax_assoc (Rmax_comm x1) -Rmax_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    apply f_equal.
    by apply IH.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  revert ptd' Hptd H ;
  apply SF_cons_ind with (s := ptd) => [ x0 | h0 s IH] s' Hs' H i Hi ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite SF_size_rev -H in Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_n_O in Hi.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_size_cons in Hi.
  apply lt_n_Sm_le in Hi.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set s'' := {| SF_h := - SF_h s; SF_t := [seq (- fst X, - snd X) | X <- SF_t s] |}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (SF_rev_cons (-fst h0,-snd h0) s'').
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_size_cons (SF_size_cons (-fst h0,-snd h0) s'') in H.
  apply eq_add_S in H.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_lx_rcons SF_ly_rcons.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?nth_rcons.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?SF_size_lx ?SF_size_ly ?SF_size_rev -H.
  move: (proj2 (SSR_leq _ _) (le_n_S _ _ Hi)) ;
  case: (ssrnat.leq (S i) (S (SF_size s))) => // _.
  apply le_lt_eq_dec in Hi ; case: Hi => [Hi | -> {i}].
  apply lt_le_S in Hi.
  move: (proj2 (SSR_leq _ _) Hi) ;
  case: (ssrnat.leq (S i) (SF_size s)) => // _.
  move: (proj2 (SSR_leq _ _) (le_n_S _ _ Hi)) ;
  case: (ssrnat.leq (S (S i)) (S (SF_size s))) => // _.
  apply IH.
  move: Hs' ; apply ptd_cons.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
  apply H.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_size_rev -H.
  intuition.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have : ~ is_true (ssrnat.leq (S (SF_size s)) (SF_size s)).
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    have H0 := lt_n_Sn (SF_size s).
    contradict H0.
    apply SSR_leq in H0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply le_not_lt.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (ssrnat.leq (S (SF_size s)) (SF_size s)) => // _.
  move: (@eqtype.eq_refl ssrnat.nat_eqType (SF_size s)) ;
  case: (@eqtype.eq_op ssrnat.nat_eqType (SF_size s) (SF_size s)) => // _.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have : ~ is_true (ssrnat.leq (S (S (SF_size s))) (S (SF_size s))).
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    have H0 := lt_n_Sn (SF_size s).
    contradict H0.
    apply SSR_leq in H0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply le_not_lt, le_S_n.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (ssrnat.leq (S (S (SF_size s))) (S (SF_size s))) => // _.
  move: (@eqtype.eq_refl ssrnat.nat_eqType (S (SF_size s))) ;
  case: (@eqtype.eq_op ssrnat.nat_eqType (S (SF_size s)) (S (SF_size s))) => // _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite H SF_lx_rev nth_rev SF_size_lx //=.
  replace (ssrnat.subn (S (SF_size s'')) (S (SF_size s'')))
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    with 0%nat by intuition.
  simpl.
  split ; apply Ropp_le_contravar ; apply (Hs' 0%nat) ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  rewrite SF_size_cons ; by apply lt_O_Sn.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rmin_opp_Rmax -Hl.
  simpl.
  clear H.
  revert ptd' ;
  move: (0) ;
  apply SF_cons_ind with (s := ptd) => [ h0 | h0 s IH] x0 s'.
  by simpl.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set s'' := {| SF_h := - SF_h s; SF_t := [seq (- fst X, - snd X) | X <- SF_t s] |}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (SF_lx_cons (-fst h0,-snd h0) s'') rev_cons /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite head_rcons.
  by apply IH.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rmax_opp_Rmin -Hh.
  simpl.
  clear H.
  revert ptd' ;
  move: (0) ;
  apply SF_cons_dec with (s := ptd) => [ h0 | h0 s] x0 s'.
  by simpl.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set s'' := {| SF_h := - SF_h s; SF_t := [seq (- fst X, - snd X) | X <- SF_t s] |}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (SF_lx_cons (-fst h0,-snd h0) s'') rev_cons /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite head_rcons.
  rewrite behead_rcons ; [ | rewrite size_rev SF_size_lx ; by apply lt_O_Sn].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite unzip1_zip.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite last_rcons.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite size_rcons size_behead ?size_rev SF_size_ly SF_size_lx //=.
  revert ptd' ;
  apply SF_cons_ind with (s := ptd) => /= [x0 | h ptd' IH].
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (if @is_left (Rle x a) (not (Rle x a)) (@right (Rle x a) (not (Rle x a)) H1) then IZR Z0 else if @is_left (Rle b x) (not (Rle b x)) (@right (Rle b x) (not (Rle b x)) H2) then IZR Z0 else f x) *)
  easy.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Riemann_sum_cons.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite (SF_rev_cons (-fst h, -snd h)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (mkSF_seq (- SF_h ptd') (seq.map (fun X : R * R => (- fst X, - snd X)) (SF_t ptd')))).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite -IH => {IH}.
  set s := {|
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
        SF_h := - SF_h ptd';
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
        SF_t := seq.map (fun X : R * R => (- fst X, - snd X)) (SF_t ptd') |}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Riemann_sum_rcons.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_lx_rev.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have H : (forall s x0, last x0 (rev s) = head x0 s).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move => T s0 x0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: s0 => [ | x1 s0] //=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite rev_cons.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by rewrite last_rcons.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite H /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite plus_comm.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: (f_equal (fun x => plus (scal x _) _)).
  simpl ; ring.
Qed.

Lemma ex_RInt_comp_opp :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a b : R),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f (-a) (-b) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt (fun y => opp (f (- y))) a b.
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (_ : ex_RInt f (Ropp a) (Ropp b)), ex_RInt (fun y : R => @opp (NormedModule.AbelianGroup R_AbsRing V) (f (Ropp y))) a b *)
  intros f a b [l If].
(* Goal: ex_RInt (fun y : R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) u (f (Rplus (Rmult u y) v))) a b *)
  exists l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply is_RInt_comp_opp.
Qed.

Lemma is_RInt_comp_lin
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (f : R -> V) (u v a b : R) (l : V) :
  is_RInt f (u * a + v) (u * b + v) l
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    -> is_RInt (fun y => scal u (f (u * y + v))) a b l.
Proof.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Req_dec u 0) => [-> {u} If | ].
  evar_last.
  apply is_RInt_ext with (fun _ => zero).
  move => x _ ; apply sym_eq ; apply: scal_zero_l.
(* Goal: is_RInt (fun _ : R => v) a b (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (Rminus b a) v) *)
  apply is_RInt_const.
  apply filterlim_locally_unique with (2 := If).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !Rmult_0_l Rplus_0_l.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite scal_zero_r.
  apply is_RInt_point.

(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  wlog: u a b / (u > 0) => [Hw | Hu _].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Rlt_le_dec 0 u) => Hu.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Hu => // Hu _ If.
    apply is_RInt_ext with (fun y => opp (scal (- u) (f ((- u) * (- y) + v)))).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move => x _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite -(scal_opp_l (- u) (f (- u * - x + v))) /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /opp /= Ropp_involutive.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    apply f_equal.
    apply f_equal ; ring.
    apply (is_RInt_comp_opp (fun y => scal (- u) (f (- u * y + v)))).
    apply Hw.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Ropp_gt_lt_0_contravar.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Ropp_neq_0_compat, Rlt_not_eq.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by rewrite ?Rmult_opp_opp.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  wlog: a b l / (a < b) => [Hw | Hab].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Rlt_le_dec a b) => Hab If.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Hab If => [Hab | -> {b}] If.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite -(opp_opp l).
    apply is_RInt_swap.
    apply Hw.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
    by apply is_RInt_swap.
    evar_last.
    apply is_RInt_point.
    apply filterlim_locally_unique with (2 := If).
    apply is_RInt_point.
  intros If.
(* Goal: is_RInt f a a (@zero (NormedModule.AbelianGroup R_AbsRing V)) *)
  apply filterlim_locally.
  generalize (proj1 (filterlim_locally _ l) If).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => {If} If eps.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (If eps) => {If} alpha If.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have Ha : 0 < alpha / Rabs u.
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    apply Rdiv_lt_0_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply alpha.
    by apply Rabs_pos_lt, Rgt_not_eq.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  exists (mkposreal _ Ha) => /= ptd Hstep [Hptd [Hfirst Hlast]].
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set ptd' := mkSF_seq (u * SF_h ptd + v) (map (fun X => (u * fst X + v,u * snd X + v)) (SF_t ptd)).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (scal (sign (b - a)) (Riemann_sum (fun y : R => scal u (f (u * y + v))) ptd))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  with (scal (sign (u * b + v - (u * a + v))) (Riemann_sum f ptd')).
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: If.
  revert ptd' ;
  case: (ptd) Hstep => x0 s Hs /= ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /seq_step /= in Hs |- *.
  elim: s x0 Hs => [ | [x1 y0] s IH] /= x0 Hs.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply alpha.
  apply Rmax_case.
  replace (u * x1 + v - (u * x0 + v)) with (u * (x1 - x0)) by ring.
  rewrite Rabs_mult Rmult_comm ; apply Rlt_div_r.
  by apply Rabs_pos_lt, Rgt_not_eq.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_lt_trans with (2 := Hs), Rmax_l.
  apply IH.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_lt_trans with (2 := Hs), Rmax_r.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  revert ptd' ;
  case: (ptd) Hptd => x0 s Hs /= i Hi ;
  rewrite /SF_size size_map /= in Hi ;
  move: (Hs i) => {Hs} Hs ;
  rewrite /SF_size /= in Hs ;
  move: (Hs Hi) => {Hs} ;
  rewrite /SF_lx /SF_ly /= => Hs.
  elim: s i x0 Hi Hs => /= [ | [x1 y0] s IH] i x0 Hi Hs.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: i Hi Hs => /= [ | i] Hi Hs.
  split ; apply Rplus_le_compat_r ;
  apply Rmult_le_compat_l ;
  try by apply Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hs.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hs.
  apply IH.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_S_n.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hs.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /ptd' /= Hfirst.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -Rplus_min_distr_r.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -Rmult_min_distr_l.
  reflexivity.
  by apply Rlt_le.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -Rplus_max_distr_r.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -Rmult_max_distr_l.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -Hlast.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /ptd' /=.
  elim: (SF_t ptd) (SF_h ptd) => [ | [x1 _] /= s IH] x0 //=.
  by apply Rlt_le.
  apply f_equal2.
  replace (u * b + v - (u * a + v)) with (u * (b - a)) by ring.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite sign_mult.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (sign_eq_1 _ Hu).
  apply Rmult_1_l.

  revert ptd' ;
  apply SF_cons_ind with (s := ptd) => [x0 | [x0 y0] s IH] //=.
  set s' := {|
      SF_h := u * SF_h s + v;
      SF_t := [seq (u * fst X + v, u * snd X + v)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
                 | X <- SF_t s] |}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Riemann_sum_cons (Riemann_sum_cons _ (u * x0 + v,u * y0 + v) s') /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite IH.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply f_equal2 => //=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite scal_assoc /=.
(* Goal: @eq (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@mult R_Ring k (sign (Rminus b a))) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@mult R_Ring (sign (Rminus b a)) k) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) *)
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k If)) *)
  apply (f_equal (fun x => scal x _)).
  rewrite /mult /= ; ring.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma ex_RInt_comp_lin (f : R -> V) (u v a b : R) :
  ex_RInt f (u * a + v) (u * b + v)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    -> ex_RInt (fun y => scal u (f (u * y + v))) a b.
Proof.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => l Hf.
(* Goal: ex_RInt (fun y : R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) u (f (Rplus (Rmult u y) v))) a b *)
  exists l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply is_RInt_comp_lin.
Qed.

(** ** Chasles *)

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma is_RInt_Chasles_0 (f : R -> V) (a b c : R) (l1 l2 : V) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a < b < c -> is_RInt f a b l1 -> is_RInt f b c l2
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  -> is_RInt f a c (plus l1 l2).
Proof.
(* Goal: forall (_ : and (Rlt a b) (Rlt b c)) (_ : is_RInt f a c l1) (_ : is_RInt f a b l2), is_RInt f b c (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  intros [Hab Hbc] H1 H2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (ex_RInt_ub f a b).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by exists l1.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /Rmin /Rmax ; case: Rle_dec (Rlt_le _ _ Hab) => //= _ _ M1 HM1.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (ex_RInt_ub f b c).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by exists l2.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /Rmin /Rmax ; case: Rle_dec (Rlt_le _ _ Hbc) => //= _ _ M2 HM2.

(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply filterlim_locally_ball_norm => eps.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  generalize (proj1 (filterlim_locally_ball_norm _ _) H1 (pos_div_2 (pos_div_2 eps))) => {H1} H1.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  generalize (proj1 (filterlim_locally_ball_norm _ _) H2 (pos_div_2 (pos_div_2 eps))) => {H2} H2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: H1 => d1 H1.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: H2 => d2 H2.
(* Goal: @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) *)
  move: H1 ; rewrite /Rmin /Rmax ; case: Rle_dec (Rlt_le _ _ Hab) => //= _ _ H1.
(* Goal: @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) *)
  move: H2 ; rewrite /Rmin /Rmax ; case: Rle_dec (Rlt_le _ _ Hbc) => //= _ _ H2.

(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have Hd3 : 0 < eps / (4 * ((M1 + 1) + (M2 + 1))).
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    apply Rdiv_lt_0_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply eps.
(* Goal: Rlt (IZR Z0) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    repeat apply Rmult_lt_0_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rlt_0_2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rlt_0_2.
(* Goal: Rgt (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) (IZR Z0) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    apply Rplus_lt_0_compat ; apply Rplus_le_lt_0_compat, Rlt_0_1.
(* Goal: Rle (IZR Z0) M1 *)
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    specialize (HM1 _ (conj (Rle_refl _) (Rlt_le _ _ Hab))).
(* Goal: Rle (IZR Z0) M1 *)
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    apply Rle_trans with (2 := HM1), norm_ge_0.
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    specialize (HM2 _ (conj (Rle_refl _) (Rlt_le _ _ Hbc))).
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    apply Rle_trans with (2 := HM2), norm_ge_0.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have Hd : 0 < Rmin (Rmin d1 d2) (mkposreal _ Hd3).
(* Goal: Rlt (IZR Z0) (Rmin (Rmin (pos d1) (pos d2)) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    repeat apply Rmin_case.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply d1.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply d2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hd3.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  exists (mkposreal _ Hd) => /= ptd Hstep [Hptd [Hh Hl]].
  move: Hh Hl ; rewrite /Rmin /Rmax ;
  case: Rle_dec (Rlt_le _ _ (Rlt_trans _ _ _ Hab Hbc)) => //= _ _ Hh Hl.
(* Goal: @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) *)
  rewrite -> sign_eq_1 by now apply Rlt_Rminus, Rlt_trans with b.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite scal_one.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /ball_norm (double_var eps).
  apply Rle_lt_trans
    with (norm (minus (Riemann_sum f ptd)
      (plus (Riemann_sum f (SF_cut_down ptd b))
            (Riemann_sum f (SF_cut_up ptd b))))
      + norm (minus (plus (Riemann_sum f (SF_cut_down ptd b))
                          (Riemann_sum f (SF_cut_up ptd b)))
                    (plus l1 l2))).
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set v:= minus _ (plus l1 l2).
  replace v
    with (plus (minus (Riemann_sum f ptd)
     (plus (Riemann_sum f (SF_cut_down ptd b))
        (Riemann_sum f (SF_cut_up ptd b))))
  (minus
     (plus (Riemann_sum f (SF_cut_down ptd b))
        (Riemann_sum f (SF_cut_up ptd b))) (plus l1 l2))).
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: norm_triangle.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /v /minus -plus_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite plus_assoc plus_opp_l plus_zero_l.
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  apply Rplus_lt_compat.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rlt_le_trans with (2 := Rmin_r _ _) in Hstep.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  generalize (fun H H0 => Riemann_sum_Chasles_0 f (M1 + 1 + (M2 + 1)) b ptd (mkposreal _ Hd3) H H0 Hptd Hstep).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite /= Hl Hh => H.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  replace (eps / 2) with (2 * (mkposreal _ Hd3) * (M1 + 1 + (M2 + 1))).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -norm_opp opp_plus opp_opp plus_comm.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
  simpl ; apply H.
(* Goal: forall (x : R) (_ : and (Rlt a x) (Rlt x b)), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  intros x Hx.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_lt_dec x b) => Hxb.
(* Goal: Rlt (@norm R_AbsRing V (f x)) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (f x)) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) *)
(* Goal: and (Rle a b) (Rle b c) *)
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rlt_trans with (M1 + 1).
(* Goal: Rlt (@norm R_AbsRing V (f x)) (Rplus M1 (IZR (Zpos xH))) *)
(* Goal: Rlt (Rplus M1 (IZR (Zpos xH))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (f x)) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) *)
(* Goal: and (Rle a b) (Rle b c) *)
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rle_lt_trans with M1.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  apply HM1 ; split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hx.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hxb.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply Rminus_lt_0 ; ring_simplify ; by apply Rlt_0_1.
(* Goal: Rlt (Rplus M2 (IZR (Zpos xH))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) *)
(* Goal: and (Rle a b) (Rle b c) *)
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rminus_lt_0 ; ring_simplify.
(* Goal: Rlt (IZR Z0) (Rplus M1 (IZR (Zpos xH))) *)
(* Goal: and (Rle a b) (Rle b c) *)
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rplus_le_lt_0_compat with (2 := Rlt_0_1).
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  specialize (HM2 _ (conj (Rle_refl _) (Rlt_le _ _ Hbc))).
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rle_trans with (2 := HM2), norm_ge_0.
(* Goal: Rlt (@norm R_AbsRing V (f x)) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) *)
(* Goal: and (Rle a b) (Rle b c) *)
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rlt_trans with (M2 + 1).
(* Goal: Rlt (@norm R_AbsRing V (f x)) (Rplus M2 (IZR (Zpos xH))) *)
(* Goal: Rlt (Rplus M2 (IZR (Zpos xH))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) *)
(* Goal: and (Rle a b) (Rle b c) *)
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rle_lt_trans with M2.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  apply HM2 ; split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Hxb.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hx.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply Rminus_lt_0 ; ring_simplify ; by apply Rlt_0_1.
(* Goal: Rlt (Rplus M2 (IZR (Zpos xH))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) *)
(* Goal: and (Rle a b) (Rle b c) *)
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rminus_lt_0 ; ring_simplify.
(* Goal: Rlt (IZR Z0) (Rplus M1 (IZR (Zpos xH))) *)
(* Goal: and (Rle a b) (Rle b c) *)
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rplus_le_lt_0_compat with (2 := Rlt_0_1).
(* Goal: Rle (IZR Z0) M1 *)
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  specialize (HM1 _ (conj (Rle_refl _) (Rlt_le _ _ Hab))).
(* Goal: Rle (IZR Z0) M1 *)
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rle_trans with (2 := HM1), norm_ge_0.
  split ; by apply Rlt_le.
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  simpl ; field.
(* Goal: not (@eq R (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) (IZR Z0)) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rgt_not_eq.
(* Goal: Rgt (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) (IZR Z0) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rplus_lt_0_compat ; apply Rplus_le_lt_0_compat, Rlt_0_1.
(* Goal: Rle (IZR Z0) M1 *)
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  specialize (HM1 _ (conj (Rle_refl _) (Rlt_le _ _ Hab))).
(* Goal: Rle (IZR Z0) M1 *)
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rle_trans with (2 := HM1), norm_ge_0.
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  specialize (HM2 _ (conj (Rle_refl _) (Rlt_le _ _ Hbc))).
(* Goal: Rle (IZR Z0) M2 *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rle_trans with (2 := HM2), norm_ge_0.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rlt_le_trans with (2 := Rmin_l _ _) in Hstep.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  specialize (H1 (SF_cut_down ptd b)).
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  specialize (H2 (SF_cut_up ptd b)).
  apply Rle_lt_trans
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    with (norm (minus (scal (sign (b - a)) (Riemann_sum f (SF_cut_down ptd b))) l1)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
         + norm (minus (scal (sign (c - b)) (Riemann_sum f (SF_cut_up ptd b))) l2)).
  replace (minus (plus (Riemann_sum f (SF_cut_down ptd b))
        (Riemann_sum f (SF_cut_up ptd b))) (plus l1 l2))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    with (plus (minus (scal (sign (b - a)) (Riemann_sum f (SF_cut_down ptd b))) l1)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
           (minus (scal (sign (c - b)) (Riemann_sum f (SF_cut_up ptd b))) l2)).
(* Goal: Rle (@norm R_AbsRing V (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply @norm_triangle.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  rewrite -> sign_eq_1 by exact: Rlt_Rminus.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  rewrite -> sign_eq_1 by exact: Rlt_Rminus.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite 2!scal_one /minus opp_plus -2!plus_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite plus_comm -plus_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply plus_comm.
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  rewrite (double_var (eps / 2)) ; apply Rplus_lt_compat.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
  apply H1.
(* Goal: Rlt (seq_step (@SF_lx R (SF_cut_down ptd b))) (pos d1) *)
(* Goal: and (pointed_subdiv (SF_cut_down ptd b)) (and (@eq R (@SF_h R (SF_cut_down ptd b)) a) (@eq R (@last R (@SF_h R (SF_cut_down ptd b)) (@unzip1 R R (@SF_t R (SF_cut_down ptd b)))) b)) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
  apply SF_cut_down_step.
  rewrite /= Hl Hh ; split ; by apply Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le_trans with (1 := Hstep), Rmin_l.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: pointed_subdiv (SF_cut_down ptd b) *)
(* Goal: and (@eq R (@SF_h R (SF_cut_down ptd b)) a) (@eq R (@last R (@SF_h R (SF_cut_down ptd b)) (@unzip1 R R (@SF_t R (SF_cut_down ptd b)))) b) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
  apply SF_cut_down_pointed.
  rewrite Hh ; by apply Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_cut_down_h.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hh.
  rewrite Hh ; by apply Rlt_le.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (SF_cut_down_l ptd b) => //=.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
  apply H2.
(* Goal: Rlt (seq_step (@SF_lx R (SF_cut_up ptd b))) (pos d2) *)
(* Goal: and (pointed_subdiv (SF_cut_up ptd b)) (and (@eq R (@SF_h R (SF_cut_up ptd b)) b) (@eq R (@last R (@SF_h R (SF_cut_up ptd b)) (@unzip1 R R (@SF_t R (SF_cut_up ptd b)))) c)) *)
  apply SF_cut_up_step.
  rewrite /= Hl Hh ; split ; by apply Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le_trans with (1 := Hstep), Rmin_r.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: pointed_subdiv (SF_cut_up ptd b) *)
(* Goal: and (@eq R (@SF_h R (SF_cut_up ptd b)) b) (@eq R (@last R (@SF_h R (SF_cut_up ptd b)) (@unzip1 R R (@SF_t R (SF_cut_up ptd b)))) c) *)
  apply SF_cut_up_pointed.
  rewrite Hh ; by apply Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite SF_cut_up_h.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (SF_cut_up_l ptd b) => /= ->.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hl.
  rewrite Hl ; by apply Rlt_le.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma ex_RInt_Chasles_0 (f : R -> V) (a b c : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a <= b <= c -> ex_RInt f a b -> ex_RInt f b c
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  -> ex_RInt f a c.
Proof.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => Hab Hbc H1 H2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Hab => [ Hab | -> ] //.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Hbc => [ Hbc | <- ] //.
(* Goal: ex_RInt f a c *)
  case: H1 => [l1 H1] ; case: H2 => [l2 H2].
(* Goal: ex_RInt f a c *)
  exists (plus l1 l2).
(* Goal: is_RInt f a c (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  apply is_RInt_Chasles_0 with b ; try assumption.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  by split.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma is_RInt_Chasles_1 (f : R -> V) (a b c : R) l1 l2 :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a < b < c -> is_RInt f a c l1 -> is_RInt f b c l2 -> is_RInt f a b (minus l1 l2).
Proof.
(* Goal: forall (_ : and (Rlt a b) (Rlt b c)) (_ : is_RInt f a c l1) (_ : is_RInt f a b l2), is_RInt f b c (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
intros [Hab Hbc] H1 H2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
apply filterlim_locally_ball_norm => eps.
generalize (proj1 (filterlim_locally_ball_norm _ _) H1 (pos_div_2 eps)) ; case => {H1} d1 /= H1.
generalize (proj1 (filterlim_locally_ball_norm _ _) H2 (pos_div_2 eps)) ; case => {H2} d2 /= H2.
exists d1 ; simpl ; intros y Hstep [Hptd [Hh Hl]].
assert (exists y, seq_step (SF_lx y) < Rmin d1 d2 /\
  pointed_subdiv y /\
  SF_h y = Rmin b c /\ last (SF_h y) (unzip1 (SF_t y)) = Rmax b c).
  apply filter_ex.
  exists (mkposreal _ (Rmin_stable_in_posreal d1 d2)) ; intros y0 H3 [H4 [H5 H6]].
  repeat (split => //=).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply H5.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply H6.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
case: H => y2 [Hstep2 H].
specialize (H2 y2 (Rlt_le_trans _ _ _ Hstep2 (Rmin_r _ _)) H).
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
case: H => Hptd2 [Hh2 Hl2].
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
set y1 := mkSF_seq (SF_h y) (SF_t y ++ SF_t y2).
  move: Hl Hh2 Hh Hl2 H1 H2 ; rewrite /Rmax /Rmin ; case: Rle_dec (Rlt_le _ _ Hab) (Rlt_le _ _ Hbc) => // _ _ ; case: Rle_dec => // _ _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec (Rlt_le _ _ (Rlt_trans _ _ _ Hab Hbc)) => // _ _.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => Hl Hh2 Hh Hl2 H1 H2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite -Hl in Hab, Hbc, H2, Hh2 |-* => {b Hl}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite -Hh in H1, Hab |- * => {a Hh}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite -Hl2 in Hbc, H2, H1 => {c Hl2}.
assert (seq_step (SF_lx y1) < d1).
  unfold y1 ; move: Hstep Hh2.
  clear -Hstep2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := y) => {y} [ x0 | [x0 y0] y IH ] /= Hstep Hl.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -Hl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le_trans with (1 := Hstep2), Rmin_l.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /SF_lx /seq_step /= in Hstep |- * ;
  move: (Rle_lt_trans _ _ _ (Rmax_r _ _) Hstep) (Rle_lt_trans _ _ _ (Rmax_l _ _) Hstep) => {Hstep} /= H H0.
  apply Rmax_case.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
  by apply IH.
assert (pointed_subdiv y1 /\ SF_h y1 = SF_h y /\
  last (SF_h y1) (unzip1 (SF_t y1)) = last (SF_h y2) (unzip1 (SF_t y2))).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  unfold y1 ; move: Hptd Hh2.
  clear -Hptd2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := y) => {y} [ x0 | [x0 y0] y IH ] /= Hptd Hl.
(* Goal: Rle b (@last R (@SF_h R ptd) (@unzip1 R R (@SF_t R ptd))) *)
  rewrite -Hl ; by apply Hptd2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => [ | i] /= Hi.
  by apply (Hptd O (lt_O_Sn _)).
  apply (IH (ptd_cons _ _ Hptd) Hl i (lt_S_n _ _ Hi)).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  unfold y1 ; simpl ; split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
  move: Hh2 ; clear ;
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := y) => {y} [ x0 | [x0 y0] y IH ] /= Hl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite Hl.
  by apply IH.
specialize (H1 y1 H H0).
move: Hab Hbc Hh2 H1 H2 ; clear ;
set c := last (SF_h y2) (unzip1 (SF_t y2)) ;
set b := last (SF_h y) (unzip1 (SF_t y)) ;
set a := SF_h y => Hab Hbc Hl.
(* Goal: @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) *)
rewrite -> sign_eq_1 by now apply Rlt_Rminus, Rlt_trans with b.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
rewrite -> sign_eq_1 by exact: Rlt_Rminus.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
rewrite -> sign_eq_1 by exact: Rlt_Rminus.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite 3!scal_one.
replace (Riemann_sum f y) with (minus (Riemann_sum f y1) (Riemann_sum f y2)).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
move => H1 H2.
unfold ball_norm.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
set v := minus _ _.
replace v
  with (minus (minus (Riemann_sum f y1) l1) (minus (Riemann_sum f y2) l2)).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (double_var eps).
  apply Rle_lt_trans with (2 := Rplus_lt_compat _ _ _ _ H1 H2).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -(norm_opp (minus (Riemann_sum f y2) l2)).
(* Goal: Rle (@norm R_AbsRing V (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  by apply @norm_triangle.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /v /minus 2!opp_plus opp_opp 2!plus_assoc.
  apply (f_equal (fun x => plus x _)).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -!plus_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply plus_comm.
  move: Hl ; unfold y1, b.
(* Goal: @eq (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@snd (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing U)) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (prod_ModuleSpace R_Ring (NormedModule.ModuleSpace R_AbsRing U) (NormedModule.ModuleSpace R_AbsRing V)) f y)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) y) *)
  clear.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := y) => {y} [ x0 | [x0 y0] y IH ] /= Hl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite -Hl /minus plus_opp_r.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (Riemann_sum_cons _ (x0,y0) {| SF_h := SF_h y; SF_t := SF_t y ++ SF_t y2 |}) /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Riemann_sum_cons /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /minus -plus_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
  by apply IH.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma is_RInt_Chasles_2 (f : R -> V) (a b c : R) l1 l2 :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a < b < c -> is_RInt f a c l1 -> is_RInt f a b l2 -> is_RInt f b c (minus l1 l2).
Proof.
(* Goal: forall (_ : and (Rlt a b) (Rlt b c)) (_ : is_RInt f a c l1) (_ : is_RInt f a b l2), is_RInt f b c (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  intros [Hab Hbc] H1 H2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -(Ropp_involutive a) -(Ropp_involutive b) -(Ropp_involutive c) in H1 H2.
(* Goal: is_RInt f b c (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  apply is_RInt_comp_opp, is_RInt_swap in H1.
(* Goal: is_RInt f b c (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  apply is_RInt_comp_opp, is_RInt_swap in H2.
(* Goal: is_RInt f b c (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  apply Ropp_lt_contravar in Hab.
(* Goal: is_RInt f b c (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  apply Ropp_lt_contravar in Hbc.
(* Goal: is_RInt f b c (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  generalize (is_RInt_Chasles_1 _ _ _ _ _ _ (conj Hbc Hab) H1 H2).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  clear => H.
(* Goal: is_RInt f b c (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  apply is_RInt_comp_opp, is_RInt_swap in H.
(* Goal: is_RInt f b c (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  replace (minus l1 l2) with (opp (minus (opp l1) (opp l2))).
(* Goal: is_RInt f b c (@opp (NormedModule.AbelianGroup R_AbsRing V) (@minus (NormedModule.AbelianGroup R_AbsRing V) (@opp (NormedModule.AbelianGroup R_AbsRing V) l1) (@opp (NormedModule.AbelianGroup R_AbsRing V) l2))) *)
(* Goal: @eq (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing V)) (@opp (NormedModule.AbelianGroup R_AbsRing V) (@minus (NormedModule.AbelianGroup R_AbsRing V) (@opp (NormedModule.AbelianGroup R_AbsRing V) l1) (@opp (NormedModule.AbelianGroup R_AbsRing V) l2))) (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  move: H ; apply is_RInt_ext.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin b c) x) (Rlt x (Rmax b c))), @eq (NormedModule.sort R_AbsRing V) (@opp (NormedModule.AbelianGroup R_AbsRing V) (@opp (NormedModule.AbelianGroup R_AbsRing V) (f (Ropp (Ropp x))))) (f x) *)
(* Goal: @eq (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing V)) (@opp (NormedModule.AbelianGroup R_AbsRing V) (@minus (NormedModule.AbelianGroup R_AbsRing V) (@opp (NormedModule.AbelianGroup R_AbsRing V) l1) (@opp (NormedModule.AbelianGroup R_AbsRing V) l2))) (@minus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) *)
  now move => x _ ; rewrite opp_opp Ropp_involutive.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite /minus opp_plus 2!opp_opp.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma is_RInt_Chasles (f : R -> V) (a b c : R) (l1 l2 : V) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b l1 -> is_RInt f b c l2
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  -> is_RInt f a c (plus l1 l2).
Proof.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  wlog: a c l1 l2 / (a <= c) => [Hw | Hac].
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move => H1 H2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Rle_lt_dec a c) => Hac.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite -(opp_opp (plus _ _)) opp_plus plus_comm.
    apply is_RInt_swap.
    apply Hw.
    by apply Rlt_le.
    by apply is_RInt_swap.
    by apply is_RInt_swap.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Req_dec a b) => [ <- {b} | Hab'] H1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  - move => H2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    apply filterlim_locally_ball_norm => /= eps.
    generalize (proj1 (filterlim_locally_ball_norm _ _) H1 (pos_div_2 eps)) ; case => /= {H1} d1 H1.
    assert (pointed_subdiv (SF_nil a) /\
      SF_h (SF_nil (T := V) a) = Rmin a a /\
      last (SF_h (SF_nil (T := V) a)) (unzip1 (SF_t (SF_nil (T := V) a))) = Rmax a a).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
      split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      move => i Hi ; by apply lt_n_O in Hi.
(* Goal: Rle b (@last R (@SF_h R ptd) (@unzip1 R R (@SF_t R ptd))) *)
      rewrite /Rmin /Rmax ; by case: Rle_dec (Rle_refl a).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    specialize (H1 (SF_nil a) (cond_pos d1) H) => {H d1}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rminus_eq_0 sign_0 in H1.
    assert (H := scal_zero_l (Riemann_sum f (SF_nil a))).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    rewrite /ball_norm H /minus plus_zero_l in H1 => {H}.
    generalize (proj1 (filterlim_locally_ball_norm _ _) H2 (pos_div_2 eps)) ; case => /= {H2} d2 H2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    exists d2 => ptd Hstep Hptd.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    apply Rle_lt_trans with (norm (minus (scal (sign (c - a)) (Riemann_sum f ptd)) l2) + norm (opp l1)).
    apply Rle_trans with (2 := norm_triangle _ _).
    apply Req_le, f_equal.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite /minus opp_plus -plus_assoc.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply f_equal, @plus_comm.
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
    rewrite (double_var eps) ; apply Rplus_lt_compat.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
    by apply H2.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
    by apply H1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  case: (Req_dec b c) => [ <- | Hbc'] H2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  - apply filterlim_locally_ball_norm => /= eps.
    generalize (proj1 (filterlim_locally_ball_norm _ _) H2 (pos_div_2 eps)) ; case => /= {H2} d2 H2.
    assert (pointed_subdiv (SF_nil b) /\
      SF_h (SF_nil (T := V) b) = Rmin b b /\
      last (SF_h (SF_nil (T := V) b)) (unzip1 (SF_t (SF_nil (T := V) b))) = Rmax b b).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
      split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      move => i Hi ; by apply lt_n_O in Hi.
(* Goal: Rle b (@last R (@SF_h R ptd) (@unzip1 R R (@SF_t R ptd))) *)
      rewrite /Rmin /Rmax ; by case: Rle_dec (Rle_refl b).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    specialize (H2 (SF_nil b) (cond_pos d2) H) => {H d2}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rminus_eq_0 sign_0 in H2.
    assert (H := scal_zero_l (Riemann_sum f (SF_nil a))).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    rewrite /ball_norm H /minus plus_zero_l in H2 => {H}.
    generalize (proj1 (filterlim_locally_ball_norm _ _) H1 (pos_div_2 eps)) ; case => /= {H1} d1 H1.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    exists d1 => ptd Hstep Hptd.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    apply Rle_lt_trans with (norm (minus (scal (sign (b - a)) (Riemann_sum f ptd)) l1) + norm (opp l2)).
    apply Rle_trans with (2 := norm_triangle _ _).
    apply Req_le, f_equal.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    by rewrite /minus opp_plus -plus_assoc.
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
    rewrite (double_var eps) ; apply Rplus_lt_compat.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
    by apply H1.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
    by apply H2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Req_dec a c) => Hac'.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  - rewrite -Hac' in H1 Hbc' H2 Hac |- * => {c Hac'}.
    apply is_RInt_swap in H2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    apply filterlim_locally_ball_norm => /= eps.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    exists (mkposreal _ Rlt_0_1) => y Hstep Hy.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rminus_eq_0 sign_0.
    assert (H := scal_zero_l (Riemann_sum f y)).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    rewrite /ball_norm H /minus plus_zero_l opp_plus => {H y Hstep Hy}.
    generalize (proj1 (filterlim_locally_ball_norm _ _) H1 (pos_div_2 eps)) ; case => /= {H1} d1 H1.
    generalize (proj1 (filterlim_locally_ball_norm _ _) H2 (pos_div_2 eps)) ; case => /= {H2} d2 H2.
    assert (exists y, seq_step (SF_lx y) < Rmin d1 d2 /\
      pointed_subdiv y /\
      SF_h y = Rmin a b /\ last (SF_h y) (unzip1 (SF_t y)) = Rmax a b).
      apply filter_ex.
      exists (mkposreal _ (Rmin_stable_in_posreal d1 d2)) ; intros y0 H3 [H4 [H5 H6]].
      repeat (split => //=).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply H5.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply H6.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: H => y [Hstep Hy].
    specialize (H1 _ (Rlt_le_trans _ _ _ Hstep (Rmin_l _ _)) Hy).
    specialize (H2 _ (Rlt_le_trans _ _ _ Hstep (Rmin_r _ _)) Hy).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite (double_var eps).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite /ball_norm -norm_opp /minus opp_plus opp_opp in H2.
    apply Rle_lt_trans with (2 := Rplus_lt_compat _ _ _ _ H1 H2).
    apply Rle_trans with (2 := norm_triangle _ _).
    apply Req_le, f_equal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite plus_assoc /minus.
    apply (f_equal (fun x => plus x _)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by rewrite plus_comm plus_assoc plus_opp_l plus_zero_l.
  case: (Rle_lt_dec a b) => Hab ; try (case: Hab => //= Hab) ; clear Hab' ;
  case: (Rle_lt_dec b c) => Hbc ; try (case: Hbc => //= Hbc) ; clear Hbc' ;
  try (case: Hac => //= Hac) ; clear Hac'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply is_RInt_Chasles_0 with b.
  apply is_RInt_swap in H2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -(opp_opp l2).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply is_RInt_Chasles_1 with b.
  apply is_RInt_swap in H1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -(opp_opp l1) plus_comm.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply is_RInt_Chasles_2 with b.
  now contradict Hab ; apply Rle_not_lt, Rlt_le, Rlt_trans with c.
Qed.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma ex_RInt_Chasles (f : R -> V) (a b c : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b -> ex_RInt f b c -> ex_RInt f a c.
Proof.
(* Goal: forall (_ : ex_RInt f a b) (_ : ex_RInt f b c), ex_RInt f a c *)
  intros [l1 H1] [l2 H2].
(* Goal: ex_RInt f a c *)
  exists (plus l1 l2).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply is_RInt_Chasles with b.
Qed.

(** ** Operations *)

Lemma is_RInt_scal :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a b : R) (k : R) (If : V),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b If ->
  is_RInt (fun y => scal k (f y)) a b (scal k If).
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a b k : R) (If : NormedModule.sort R_AbsRing V) (_ : is_RInt f a b If), is_RInt (fun y : R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k (f y)) a b (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k If) *)
intros f a b k If Hf.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
apply filterlim_ext with (fun ptd => scal k (scal (sign (b - a)) (Riemann_sum f ptd))).
(* Goal: forall x : @SF_seq R, @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g x))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun y : R => @plus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) x)) *)
(* Goal: @filterlim (@SF_seq R) (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (fun ptd : @SF_seq R => @plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@plus (NormedModule.AbelianGroup R_AbsRing V) If Ig)) *)
intros ptd.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Riemann_sum_scal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite 2!scal_assoc.
(* Goal: @eq (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@mult R_Ring k (sign (Rminus b a))) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@mult R_Ring (sign (Rminus b a)) k) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) *)
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k If)) *)
apply (f_equal (fun x => scal x _)).
(* Goal: @eq (Ring.sort R_Ring) (@mult R_Ring k (sign (Rminus b a))) (@mult R_Ring (sign (Rminus b a)) k) *)
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k If)) *)
apply Rmult_comm.
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (IZR (Zpos xH))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@opp (NormedModule.AbelianGroup R_AbsRing V) If)) *)
apply filterlim_comp with (1 := Hf).
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: filterlim_scal_r.
Qed.

Lemma ex_RInt_scal :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a b : R) (k : R),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b ->
  ex_RInt (fun y => scal k (f y)) a b.
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a b k : R) (_ : ex_RInt f a b), ex_RInt (fun y : R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k (f y)) a b *)
intros f a b k [If Hf].
(* Goal: ex_RInt (fun y : R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k (f y)) a b *)
exists (scal k If).
(* Goal: is_RInt (fun y : R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k (f y)) a b (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k If) *)
now apply is_RInt_scal.
Qed.

Lemma is_RInt_opp :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a b : R) (If : V),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b If ->
  is_RInt (fun y => opp (f y)) a b (opp If).
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (If : NormedModule.sort R_AbsRing V) (_ : is_RInt f a b If), is_RInt (fun y : R => @opp (NormedModule.AbelianGroup R_AbsRing V) (f y)) a b (@opp (NormedModule.AbelianGroup R_AbsRing V) If) *)
intros f a b If Hf.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
apply filterlim_ext with (fun ptd => (scal (opp 1) (scal (sign (b - a)) (Riemann_sum f ptd)))).
(* Goal: forall x : @SF_seq R, @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g x))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun y : R => @plus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) x)) *)
(* Goal: @filterlim (@SF_seq R) (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (fun ptd : @SF_seq R => @plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@plus (NormedModule.AbelianGroup R_AbsRing V) If Ig)) *)
intros ptd.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Riemann_sum_opp.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite scal_opp_one.
(* Goal: @eq (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) *)
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (IZR (Zpos xH))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@opp (NormedModule.AbelianGroup R_AbsRing V) If)) *)
apply sym_eq, scal_opp_r.
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (IZR (Zpos xH))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@opp (NormedModule.AbelianGroup R_AbsRing V) If)) *)
apply filterlim_comp with (1 := Hf).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
rewrite -(scal_opp_one If).
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: filterlim_scal_r.
Qed.

Lemma ex_RInt_opp :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a b : R),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b ->
  ex_RInt (fun x => opp (f x)) a b.
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (_ : ex_RInt f a b), ex_RInt (fun x : R => @opp (NormedModule.AbelianGroup R_AbsRing V) (f x)) a b *)
intros f a b [If Hf].
(* Goal: ex_RInt (fun x : R => @opp (NormedModule.AbelianGroup R_AbsRing V) (f x)) a b *)
exists (opp If).
(* Goal: is_RInt (fun x : R => @opp (NormedModule.AbelianGroup R_AbsRing V) (f x)) a b (@opp (NormedModule.AbelianGroup R_AbsRing V) If) *)
now apply is_RInt_opp.
Qed.

Lemma is_RInt_plus :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f g : R -> V) (a b : R) (If Ig : V),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b If ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt g a b Ig ->
  is_RInt (fun y => plus (f y) (g y)) a b (plus If Ig).
Proof.
(* Goal: forall (f g : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (If Ig : NormedModule.sort R_AbsRing V) (_ : is_RInt f a b If) (_ : is_RInt g a b Ig), is_RInt (fun y : R => @plus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) a b (@plus (NormedModule.AbelianGroup R_AbsRing V) If Ig) *)
intros f g a b If Ig Hf Hg.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
apply filterlim_ext with (fun ptd => (plus (scal (sign (b - a)) (Riemann_sum f ptd)) (scal (sign (b - a)) (Riemann_sum g ptd)))).
(* Goal: forall x : @SF_seq R, @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g x))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun y : R => @plus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) x)) *)
(* Goal: @filterlim (@SF_seq R) (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (fun ptd : @SF_seq R => @plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@plus (NormedModule.AbelianGroup R_AbsRing V) If Ig)) *)
intros ptd.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Riemann_sum_plus.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g ptd))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g ptd))) *)
(* Goal: @filterlim (@SF_seq R) (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (fun ptd : @SF_seq R => @plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@plus (NormedModule.AbelianGroup R_AbsRing V) If Ig)) *)
apply sym_eq, @scal_distr_l.
(* Goal: @filterlim (@SF_seq R) (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (fun ptd : @SF_seq R => @plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@plus (NormedModule.AbelianGroup R_AbsRing V) If Ig)) *)
apply filterlim_comp_2 with (1 := Hf) (2 := Hg).
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: filterlim_plus.
Qed.

Lemma ex_RInt_plus :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f g : R -> V) (a b : R),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt g a b ->
  ex_RInt (fun y => plus (f y) (g y)) a b.
Proof.
(* Goal: forall (f g : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (_ : ex_RInt f a b) (_ : ex_RInt g a b), ex_RInt (fun y : R => @minus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) a b *)
intros f g a b [If Hf] [Ig Hg].
(* Goal: ex_RInt (fun y : R => @plus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) a b *)
exists (plus If Ig).
(* Goal: is_RInt (fun y : R => @plus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) a b (@plus (NormedModule.AbelianGroup R_AbsRing V) If Ig) *)
now apply is_RInt_plus.
Qed.

Lemma is_RInt_minus :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f g : R -> V) (a b : R) (If Ig : V),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b If ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt g a b Ig ->
  is_RInt (fun y => minus (f y) (g y)) a b (minus If Ig).
Proof.
(* Goal: forall (f g : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (If Ig : NormedModule.sort R_AbsRing V) (_ : is_RInt f a b If) (_ : is_RInt g a b Ig), is_RInt (fun y : R => @plus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) a b (@plus (NormedModule.AbelianGroup R_AbsRing V) If Ig) *)
intros f g a b If Ig Hf Hg.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
apply filterlim_ext with (fun ptd => (plus (scal (sign (b - a)) (Riemann_sum f ptd)) (scal (opp 1) (scal (sign (b - a)) (Riemann_sum g ptd))))).
(* Goal: forall x : @SF_seq R, @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g x))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun y : R => @plus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) x)) *)
(* Goal: @filterlim (@SF_seq R) (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (fun ptd : @SF_seq R => @plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@plus (NormedModule.AbelianGroup R_AbsRing V) If Ig)) *)
intros ptd.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Riemann_sum_minus.
unfold minus.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite scal_opp_one.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
rewrite -scal_opp_r.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g ptd))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g ptd))) *)
(* Goal: @filterlim (@SF_seq R) (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (fun ptd : @SF_seq R => @plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) g ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@plus (NormedModule.AbelianGroup R_AbsRing V) If Ig)) *)
apply sym_eq, @scal_distr_l.
eapply filterlim_comp_2 with (1 := Hf).
apply filterlim_comp with (1 := Hg).
eapply @filterlim_scal_r.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite scal_opp_one.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: filterlim_plus.
Qed.

Lemma ex_RInt_minus :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f g : R -> V) (a b : R),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt g a b ->
  ex_RInt (fun y => minus (f y) (g y)) a b.
Proof.
(* Goal: forall (f g : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (_ : ex_RInt f a b) (_ : ex_RInt g a b), ex_RInt (fun y : R => @minus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) a b *)
intros f g a b [If Hf] [Ig Hg].
(* Goal: ex_RInt (fun y : R => @minus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) a b *)
exists (minus If Ig).
(* Goal: is_RInt (fun y : R => @minus (NormedModule.AbelianGroup R_AbsRing V) (f y) (g y)) a b (@minus (NormedModule.AbelianGroup R_AbsRing V) If Ig) *)
now apply is_RInt_minus.
Qed.

End is_RInt.

Lemma ex_RInt_Chasles_1 {V : CompleteNormedModule R_AbsRing}
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (f : R -> V) (a b c : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a <= b <= c -> ex_RInt f a c -> ex_RInt f a b.
Proof.
  intros [Hab Hbc] If.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  case: Hab => [Hab | <- ].
  2: by apply ex_RInt_point.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  assert (H1 := filterlim_locally_cauchy (F := (Riemann_fine a b)) (fun ptd : SF_seq => scal (sign (b - a)) (Riemann_sum f ptd))).
  apply H1 ; clear H1.
  intros eps.

  set (M := @norm_factor _ V).
  assert (He : 0 < eps / M).
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    apply Rdiv_lt_0_compat.
    apply cond_pos.
    apply norm_factor_gt_0.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  assert (H1 := proj2 (filterlim_locally_cauchy (F := (Riemann_fine a c)) (fun ptd : SF_seq => scal (sign (c - a)) (Riemann_sum f ptd)))).
  destruct (H1 If (mkposreal _ He)) as [P [[alpha HP] H2]] ; clear If H1 ; rename H2 into If.
  destruct (filter_ex (F := Riemann_fine b c) (fun y => seq_step (SF_lx y) < alpha
    /\ pointed_subdiv y /\
     SF_h y = Rmin b c /\ seq.last (SF_h y) (SF_lx y) = Rmax b c)) as [y' Hy'].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by exists alpha.

(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  exists (fun y => P (SF_cat y y') /\ last (SF_h y) (SF_lx y) = Rmax a b) ; split.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
  exists alpha ; intros.
  assert (last 0 (SF_lx y) = head 0 (SF_lx y')).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    simpl in H0, Hy' |- *.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite (proj1 (proj2 (proj2 Hy'))).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite (proj2 (proj2 H0)).
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    rewrite /Rmin ; case: Rle_dec => // _.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    rewrite /Rmax ; case: Rle_dec (Rlt_le _ _ Hab) => //.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply HP ; intuition.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_lx_cat seq_step_cat.
  by apply Rmax_case.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cat_pointed => //.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite H3 /Rmin ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec (Rlt_le _ _ (Rlt_le_trans _ _ _ Hab Hbc)) => //.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_last_cat // H8.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /Rmax ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec (Rlt_le _ _ (Rlt_le_trans _ _ _ Hab Hbc)) => //.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply H0.

(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
  intros.
  specialize (If _ _ (proj1 H) (proj1 H0)).
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  rewrite -> sign_eq_1 by exact: Rlt_Rminus.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -> sign_eq_1 in If by now apply Rlt_Rminus, Rlt_le_trans with b.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: norm_compat1.
  eapply Rlt_le_trans.
  eapply Rle_lt_trans.
  2: apply norm_compat2 with (1 := If).
  apply Req_le, f_equal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !scal_one.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
  case: H => _ ; case: H0 => _ ; clear ; intros.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -b1 in b0.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: v u b0 y' {b1}.
  apply (SF_cons_ind (fun v => forall u : SF_seq,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    last (SF_h v) (SF_lx v) = last (SF_h u) (SF_lx u) ->
    forall y' : SF_seq,
    minus (Riemann_sum f v) (Riemann_sum f u) =
    minus (Riemann_sum f (SF_cat v y')) (Riemann_sum f (SF_cat u y')))) => [v0 | v0 v IH u Huv y].
  apply (SF_cons_ind (fun u =>
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    last (SF_h (SF_nil v0)) (SF_lx (SF_nil v0)) = last (SF_h u) (SF_lx u) ->
    forall y' : SF_seq,
    minus (Riemann_sum f (SF_nil v0)) (Riemann_sum f u) =
    minus (Riemann_sum f (SF_cat (SF_nil v0) y')) (Riemann_sum f (SF_cat u y')))) => [u0 /= Huv | u0 u IH Huv y].
  apply (SF_cons_ind (fun y' : SF_seq =>
    minus (Riemann_sum f (SF_nil v0)) (Riemann_sum f (SF_nil u0)) =
    minus (Riemann_sum f (SF_cat (SF_nil v0) y'))
      (Riemann_sum f (SF_cat (SF_nil u0) y')))) => [y0 | y0 y IH].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
  simpl in Huv.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Huv /SF_cat /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (Riemann_sum_cons _ (u0,snd y0)) /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /minus opp_plus (plus_comm (scal _ _)) -plus_assoc.
  now rewrite (plus_assoc (scal _ _)) !plus_opp_r plus_zero_l plus_opp_r.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -SF_cons_cat !Riemann_sum_cons.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /minus !opp_plus !(plus_comm (opp (scal _ _))) !plus_assoc.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  by rewrite -!/(minus _ _) -IH.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -SF_cons_cat !Riemann_sum_cons.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /minus -!plus_assoc.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  by rewrite -!/(minus _ _) -IH.
  fold M.
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Req_le ; simpl ; field.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rgt_not_eq, norm_factor_gt_0.
Qed.

Lemma ex_RInt_Chasles_2 {V : CompleteNormedModule R_AbsRing}
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (f : R -> V) (a b c : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
   a <= b <= c -> ex_RInt f a c -> ex_RInt f b c.
Proof.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
  intros.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -(Ropp_involutive a) -(Ropp_involutive c)
    in H0.
  apply ex_RInt_comp_opp in H0.
  apply ex_RInt_swap in H0.
  eapply ex_RInt_Chasles_1 in H0.
  apply ex_RInt_comp_opp in H0.
  apply ex_RInt_swap in H0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  move: H0 ; apply ex_RInt_ext => x _.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite opp_opp Ropp_involutive.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
  split ; apply Ropp_le_contravar ; apply H.
Qed.

Lemma ex_RInt_inside {V : CompleteNormedModule R_AbsRing} :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a b x e : R),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f (x-e) (x+e) -> Rabs (a-x) <= e -> Rabs (b-x) <= e ->
  ex_RInt f a b.
Proof.
(* Goal: forall (f : forall _ : R, CompleteNormedModule.sort R_AbsRing V) (a b x e : R) (_ : @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f (Rminus x e) (Rplus x e)) (_ : Rle (Rabs (Rminus a x)) e) (_ : Rle (Rabs (Rminus b x)) e), @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b *)
intros f a b x e Hf Ha Hb.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
wlog: a b Ha Hb / (a <= b) => [Hw | Hab].
(* Goal: @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b *)
(* Goal: @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b *)
case (Rle_or_lt a b); intros H.
now apply Hw.
(* Goal: @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b *)
(* Goal: @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b *)
apply ex_RInt_swap.
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (if @is_left (Rle x a) (not (Rle x a)) (@right (Rle x a) (not (Rle x a)) H1) then IZR Z0 else if @is_left (Rle b x) (not (Rle b x)) (@right (Rle b x) (not (Rle b x)) H2) then IZR Z0 else f x) *)
apply Hw; try easy.
(* Goal: Rle b a *)
(* Goal: @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b *)
now left.
(* Goal: @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b *)
apply (ex_RInt_Chasles_1 f a b) with (x+e).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
split.
(* Goal: Rle a b *)
(* Goal: Rle b (Rplus x e) *)
(* Goal: @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a (Rplus x e) *)
exact Hab.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
assert (x-e <= b <= x+e) by now apply Rabs_le_between'.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
apply H.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
apply ex_RInt_Chasles_2 with (x-e).
(* Goal: and (Rle (Rminus x e) a) (Rle a (Rplus x e)) *)
(* Goal: @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f (Rminus x e) (Rplus x e) *)
now apply Rabs_le_between'.
(* Goal: @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f (Rminus x e) (Rplus x e) *)
exact Hf.
Qed.

(** ** Exchange limit and integral *)

Lemma filterlim_RInt {U} {V : CompleteNormedModule R_AbsRing} :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : U -> R -> V) (a b : R) F (FF : ProperFilter F)
    g h,
  (forall x, is_RInt (f x) a b (h x))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  -> (filterlim f F (locally g))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  -> exists If, filterlim h F (locally If) /\ is_RInt g a b If.
Proof.
intros f a b F FF g h Hfh Hfg.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
wlog: a b h Hfh / (a <= b) => [Hw | Hab].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_lt_dec a b) => Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hw.
  destruct (Hw b a (fun x => opp (h x))) as [If [Hfh' Hfg']].
  intro x.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply @is_RInt_swap.
  by apply Rlt_le.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  exists (opp If) ; split.
  apply filterlim_ext with (fun x => opp (opp (h x))).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => x.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply opp_opp.
  eapply (filterlim_comp _ _ _ (fun x => opp (h x)) opp).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hfh'.
  now generalize (filterlim_opp If).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply @is_RInt_swap.

(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
case: Hab => Hab.

destruct (fun FF2 HF2 => filterlim_switch_dom
  F FF (locally_dist (fun ptd : SF_seq.SF_seq => SF_seq.seq_step (SF_seq.SF_lx ptd))) FF2
  (fun ptd : SF_seq.SF_seq => SF_seq.pointed_subdiv ptd /\
    SF_seq.SF_h ptd = Rmin a b /\
    seq.last (SF_seq.SF_h ptd) (SF_seq.SF_lx ptd) = Rmax a b) HF2
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (fun (x : U) ptd => scal (sign (b - a)) (Riemann_sum (f x) ptd))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (fun ptd => scal (sign (b - a)) (Riemann_sum g ptd)) h) as [If [Hh Hg]].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
by apply locally_dist_filter.
intros P [eP HP].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
assert (Hn : 0 <= ((b - a) / eP)).
    apply Rdiv_le_0_compat.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    apply -> Rminus_le_0.
    apply Rlt_le, Hab.
    apply cond_pos.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set n := (nfloor _ Hn).
  exists (SF_seq.SF_seq_f2 (fun x y => x) (SF_seq.unif_part (Rmin a b) (Rmax a b) n)).
  destruct (Riemann_fine_unif_part (fun x y => x) a b n).
  intros u v Huv.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  apply Rle_refl.
  exact Huv.
  now apply Rlt_le, Hab.
  rewrite /Rmin /Rmax ; case: Rle_dec (Rlt_le _ _ Hab)  => // _ _.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply H0.
(* Goal: P (@snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) y) *)
(* Goal: @filtermap (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd)) (Riemann_fine a b) P *)
  apply HP.
  apply Rle_lt_trans with (1 := H).
  apply Rlt_div_l.
  apply INRp1_pos.
  unfold n, nfloor.
  destruct nfloor_ex as [n' Hn'].
  simpl.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rmult_comm.
  apply Rlt_div_l.
  apply cond_pos.
  apply Hn'.
  rewrite /Rmin /Rmax ; case: Rle_dec (Rlt_le _ _ Hab)  => // _ _.
2: by apply Hfh.

set (M := @norm_factor _ V).
intros P [eps HP].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
have He: 0 < (eps / (b - a)) / (2 * M).
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  apply Rdiv_lt_0_compat.
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  apply Rdiv_lt_0_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply eps.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  by rewrite -Rminus_lt_0.
  apply Rmult_lt_0_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_0_2.
  apply norm_factor_gt_0.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
generalize (Hfg _ (locally_ball g (mkposreal _ He))) => {Hfg Hfh}.
unfold filtermap ;
apply filter_imp => x Hx.
(* Goal: P (@snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) y) *)
(* Goal: @filtermap (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd)) (Riemann_fine a b) P *)
apply HP.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
case => t [Ht [Ha Hb]] /=.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
rewrite -> sign_eq_1 by exact: Rlt_Rminus.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite 2!scal_one.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: norm_compat1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
generalize (Riemann_sum_minus (f x) g t) => <-.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
refine (_ (Riemann_sum_norm (fun x0 : R => minus (f x x0) (g x0)) (fun _ => M * ((eps / (b - a)) / (2 * M))) t Ht _)).
move => H ; apply Rle_lt_trans with (1 := H).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Riemann_sum_const.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Hb Ha.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite /scal /= /mult /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
replace ((b - a) * (M * ((eps / (b - a)) / (2 * M)))) with (eps / 2).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
rewrite {2}(double_var eps) -{1}(Rplus_0_l (eps / 2)).
apply Rplus_lt_compat_r.
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
apply Rdiv_lt_0_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
by apply eps.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
by apply Rlt_0_2.
field.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
split.
(* Goal: not (@eq R (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) (IZR Z0)) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
apply Rgt_not_eq.
apply Rlt_gt.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
by rewrite -Rminus_lt_0.
(* Goal: not (@eq R (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) (IZR Z0)) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
apply Rgt_not_eq.
apply norm_factor_gt_0.
intros t0 Ht0.
apply Rlt_le.
apply (norm_compat2 _ _ (mkposreal _ He) (Hx t0)).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
exists If ; split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
by apply Hh.
by apply Hg.

exists zero.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
rewrite -Hab in Hfh |- * => {b Hab}.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
split.
apply filterlim_ext with (fun _ => zero).
(* Goal: forall x : @SF_seq R, @eq (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (@one R_Ring)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus a b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x)) *)
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (@one R_Ring)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus a b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing V) (@opp (Ring.AbelianGroup (AbsRing.Ring R_AbsRing)) (@one (AbsRing.Ring R_AbsRing))) If)) *)
intros x.
apply filterlim_locally_unique with (2 := Hfh x).
apply is_RInt_point.
apply filterlim_const.
apply is_RInt_point.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
(** ** Continuous imply Riemann-integrable *)

Section StepFun.

Context {V : NormedModule R_AbsRing}.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma is_RInt_SF (f : R -> V) (s : SF_seq) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  SF_sorted Rle s ->
  let a := SF_h s in
  let b := last (SF_h s) (unzip1 (SF_t s)) in
  is_RInt (SF_fun (SF_map f s) zero) a b (Riemann_sum f s).
Proof.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := s) => {s} [ x0 | x0 s IH] Hsort a b.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Riemann_sum_zero //.
  by apply is_RInt_point.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  - rewrite Riemann_sum_cons.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) a b (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (Rminus (@SF_h R s) (@fst R R x0)) (f (@snd R R x0))) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s)) *)
    apply is_RInt_Chasles with (SF_h s).
    move: (proj1 Hsort) ;
    unfold a ; clear IH Hsort a b ; simpl => Hab.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@fst R R x0) (@SF_h R s) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (Rminus (@SF_h R s) (@fst R R x0)) (f (@snd R R x0))) *)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    eapply is_RInt_ext, is_RInt_const.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    rewrite /Rmin /Rmax ; case: Rle_dec => // _ x Hx.
    unfold SF_fun ; simpl.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Rlt_dec => //= H.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (f (@snd R R x0)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (f (@snd R R x0)) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    contradict H ; apply Rle_not_lt, Rlt_le, Hx.
    move: Hab Hx ;
    apply SF_cons_dec with (s := s) => {s} /= [x1 | x1 s] Hab Hx.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Rle_dec (Rlt_le _ _ (proj2 Hx)) => //.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Rlt_dec (proj2 Hx) => //.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  - eapply is_RInt_ext, IH.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) b) x) (Rlt x (Rmax (@SF_h R s) b))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    clear a IH.
    revert b ; simpl.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    rewrite /Rmin /Rmax ; case: Rle_dec => // Hab x Hx.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /SF_fun /=.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Rlt_dec => /= Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@zero (NormedModule.AbelianGroup R_AbsRing V)) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    contradict Hx0.
(* Goal: not (Rlt x (@fst R R x0)) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    apply Rle_not_lt.
(* Goal: Rle (@fst R R x0) x *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    eapply Rle_trans, Rlt_le, Hx.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hsort.
    move: Hab Hx Hsort ;
    apply SF_cons_dec with (s := s) => {s} [x1 | x1 s] //= Hab Hx Hsort.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Hx => H H'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rle_dec x x1 then @zero (NormedModule.AbelianGroup R_AbsRing V) else @zero (NormedModule.AbelianGroup R_AbsRing V)) (if Rle_dec x x1 then f (@snd R R x0) else @zero (NormedModule.AbelianGroup R_AbsRing V)) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    contradict H' ; by apply Rle_not_lt, Rlt_le.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Rlt_dec => //= H.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@zero (NormedModule.AbelianGroup R_AbsRing V)) (f (@snd R R x0)) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    contradict H ; by apply Rle_not_lt, Rlt_le, Hx.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    contradict Hab.
(* Goal: Rle (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s))) *)
(* Goal: @SF_sorted R Rle s *)
    apply (sorted_last ((SF_h s) :: (unzip1 (SF_t s))) O (proj2 Hsort) (lt_O_Sn _) (SF_h s)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hsort.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma ex_RInt_SF (f : R -> V) (s : SF_seq) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  SF_sorted Rle s ->
  let a := SF_h s in
  let b := last (SF_h s) (unzip1 (SF_t s)) in
  ex_RInt (SF_fun (SF_map f s) zero) a b.
Proof.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
  intros.
  eexists.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply is_RInt_SF.
Qed.

End StepFun.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma ex_RInt_continuous {V : CompleteNormedModule R_AbsRing} (f : R -> V) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall z, Rmin a b <= z <= Rmax a b -> continuous f z)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  -> ex_RInt f a b.
Proof.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  wlog: f / (forall z : R, continuous f z) => [ Hw Cf | Cf _ ].
    destruct (C0_extension_le f (Rmin a b) (Rmax a b)) as [g [Cg Hg]].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Cf.
    apply ex_RInt_ext with g.
    intros x Hx ; apply Hg ; split ; apply Rlt_le ; apply Hx.
    apply Hw => // z _ ; by apply Cg.

(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  wlog: a b / (a < b) => [Hw | Hab].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Rle_lt_dec a b) => Hab.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Hab => Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.
(* Goal: Rle b (@last R (@SF_h R ptd) (@unzip1 R R (@SF_t R ptd))) *)
    rewrite Hab ; by apply ex_RInt_point.
(* Goal: @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b *)
(* Goal: @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b *)
    apply ex_RInt_swap.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.

  assert (H := unifcont_normed_1d f a b (fun x Hx => Cf x)).

(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set n := fun eps => proj1_sig (seq_step_unif_part_ex a b (proj1_sig (H eps))).
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set s := fun eps => (SF_seq_f2 (fun x y => ((x+y)/2)%R) (unif_part a b (n eps))).
  set (f_eps := fun eps => fun x => match (Rle_dec a x) with
    | left _ => match (Rle_dec x b) with
       | left _ => SF_fun (SF_map f (s eps)) zero x
       | right _ => f x
       end
     | right _ => f x
     end).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  set F := fun (P : posreal -> Prop) => exists eps : posreal, forall x : posreal,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    x < eps -> P x.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set If_eps := fun eps => Riemann_sum f (s eps).

  assert (FF : ProperFilter F).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  - assert (forall P, F P <-> at_right 0 (fun x => 0 < x /\ forall Hx, P (mkposreal x Hx))).
      split ; intros [e He].
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
      exists e => y Hy H0 ; split => //.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
      move => {H0} H0.
      apply He.
      eapply Rle_lt_trans, Hy.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite minus_zero_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply Req_le, sym_eq, Rabs_pos_eq, Rlt_le.
      exists e ; intros [ y H0] Hy.
      apply He.
      apply Rabs_lt_between.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
      rewrite minus_zero_r ; split.
      eapply Rlt_trans, H0.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      rewrite -Ropp_0 ; apply Ropp_lt_contravar, e.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply Hy.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply H0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (at_right_proper_filter 0) => H1 H2.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
    + intros P HP.
      apply H0 in HP.
      destruct (H1 _ HP) as [x [Hx Px]].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by exists (mkposreal x Hx).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
      destruct H2 ; split.
    + by exists (mkposreal _ Rlt_0_1).
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
    + intros.
      apply H0.
      eapply filter_imp.
      2: apply filter_and ; apply H0.
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
      2: apply H2.
      2: apply H3.
      intuition ; apply H4.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
    + intros.
      apply H0.
      eapply filter_imp.
      2: apply H0 ; apply H3.
      intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply H4.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply H2, H4.
  assert (Ha : forall eps, a = (SF_h (s eps))).
    intros eps ; simpl.
    rewrite /Rdiv ; ring.
  assert (Hb : forall eps, b = (last (SF_h (s eps)) (unzip1 (SF_t (s eps))))).
    intros eps.
    rewrite -(last_unif_part 0 a b (n eps)) ; simpl.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
    apply f_equal.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    elim: {2 4}(n eps) (a + 1 * (b - a) / (INR (n eps) + 1))%R (2%nat) => [ | m IH] //= x0 k.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    by rewrite -IH.
  destruct (filterlim_RInt f_eps a b F FF f If_eps) as [If HI].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  - intros eps.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite (Ha eps) (Hb eps).
    eapply is_RInt_ext.
    2: apply (is_RInt_SF f (s eps)).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite -Hb -Ha.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    rewrite /Rmin /Rmax ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _ x [Hax Hxb].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /f_eps.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Rle_dec (Rlt_le _ _ Hax) => // _ _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Rle_dec (Rlt_le _ _ Hxb) => // _ _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /s /SF_sorted SF_lx_f2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply unif_part_sort, Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_O_Sn.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  - apply (filterlim_locally f_eps) => /= eps.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /ball /= /fct_ball.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    exists eps => e He t.
    eapply ball_le.
    apply Rlt_le, He.
    apply (norm_compat1 (f t) (f_eps e t) e).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /f_eps.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Rle_dec => Hat.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Rle_dec => Hta.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite SF_fun_incr.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite SF_map_lx SF_lx_f2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply unif_part_sort, Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_O_Sn.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite SF_map_lx SF_lx_f2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite last_unif_part head_unif_part.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    by split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_O_Sn.
    intros Hsort Ht.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: sorted_dec.
    + rewrite SF_map_lx SF_lx_f2.
      intros Hi ; set i := proj1_sig Hi.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_map_ly (nth_map 0).
      apply (proj2_sig (H e)).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
      by split.
      split ; eapply Rle_trans.
      2: apply ptd_f2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_lx_f2 {1}(Ha e).
      apply sorted_head.
      apply unif_part_sort.
      by apply Rlt_le.
      eapply lt_trans, (proj2_sig Hi).
      eapply lt_trans ; apply lt_n_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply unif_part_sort, Rlt_le.
      intros x y Hxy.
      lra.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_size_f2.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
      move: (proj2 (proj2_sig Hi)).
      unfold i.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
      case: (size (unif_part a b (n e))) (proj1_sig Hi) => [ | m] /= k Hk.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_n_O in Hk.
      apply lt_S_n.
      eapply lt_trans, Hk.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_n_Sn.
      apply ptd_f2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply unif_part_sort, Rlt_le.
      intros x y Hxy.
      lra.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_size_f2.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
      move: (proj2 (proj2_sig Hi)).
      unfold i ;
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
      case: (size (unif_part a b (n e))) (proj1_sig Hi) => [ | m] /= k Hk.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_n_O in Hk.
      apply lt_S_n.
      eapply lt_trans, Hk.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_n_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite SF_lx_f2 ; try by apply lt_O_Sn.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite {2}(Hb e).
      eapply Rle_trans, (sorted_last _ i).
      apply Req_le.
      unfold s ; simpl.
      unfold i ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      elim: {1 3 6}(n e) (2%nat) (a + 1 * (b - a) / (INR (n e) + 1))%R (proj1_sig Hi) (proj2 (proj2_sig Hi)) => [ | m IH] // k x0 j Hj.
      simpl in Hj ;
      by apply lt_S_n, lt_S_n, lt_n_O in Hj.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
      case: j Hj => [ | j] Hj //=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      rewrite -IH //.
      apply lt_S_n.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite size_mkseq.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by rewrite size_mkseq in Hj.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
      move: (unif_part_sort a b (n e) (Rlt_le _ _ Hab)).
      unfold s.
      elim: (unif_part a b (n e)) => [ | h] //=.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
      case => [ | h0 l] IH // [Hh Hl].
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
      move: (IH Hl) => /=.
      case: l Hl {IH} => //= ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      split => // ; by apply Hl.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      rewrite size_mkseq in Hi, i |- *.
      apply lt_S_n.
      eapply lt_le_trans.
      eapply lt_trans, (proj2_sig Hi).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_n_Sn.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite /s.
      elim: (n e) (a) (b) => [ | m IH] // a' b'.
      apply le_n_S ; rewrite unif_part_S ; by apply IH.
      apply Rle_lt_trans with (norm (minus (nth 0 (unif_part a b (n e)) (S i))
      (nth 0 (unif_part a b (n e)) i))).
      change norm with Rabs.
      apply Rabs_le_between ; rewrite Rabs_pos_eq.
      change minus with Rminus ; rewrite Ropp_minus_distr'.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite /i {i}.
      destruct Hi as [i [[H1 H2] H3]].
      simpl sval.
      cut (nth 0 (unif_part a b (n e)) i <= nth 0 (SF_ly (s e)) i <= nth 0 (unif_part a b (n e)) (S i)).
        lra.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_ly_f2 nth_behead (nth_pairmap 0).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      move: {-2 4}(S i) H2 => Si /= ; clear -H1 H3 ; lra.
      now apply SSR_leq, lt_le_weak.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      apply -> Rminus_le_0.
      apply (sorted_nth Rle (unif_part a b (n e))).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply unif_part_sort, Rlt_le.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
      move: (proj2 (proj2_sig Hi)).
      unfold i ;
      case: (size (unif_part a b (n e))) (proj1_sig Hi) => [ | m] j /= Hm.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_n_O in Hm.
      apply lt_S_n.
      eapply lt_trans, Hm.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_n_Sn.
      eapply Rle_lt_trans.
      apply nth_le_seq_step.
      eapply lt_trans, (proj2_sig Hi).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_n_S.
      apply (proj2_sig (seq_step_unif_part_ex a b (proj1_sig (H e)))).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SSR_leq.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_size_ly.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      apply le_S_n ; rewrite -SF_size_lx.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_lx_f2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_le_weak, (proj2_sig Hi).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_O_Sn.
    + intros Hi.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
      move: Hsort Ht Hi.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_map_lx SF_size_map SF_size_lx.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_lx_f2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      rewrite -SF_size_ly SF_ly_f2 size_behead size_pairmap size_mkseq.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      simpl (S (Peano.pred (S (S (n e)))) - 2)%nat.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      simpl (S (Peano.pred (S (S (n e)))) - 1)%nat.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      simpl (Peano.pred (S (S (n e))) - 1)%nat.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      rewrite -minus_n_O.
      intros Hsort Ht Hi.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_map_ly (nth_map 0).
      apply (proj2_sig (H e)).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
      by split.
      split ; eapply Rle_trans.
      2: apply ptd_f2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_lx_f2 {1}(Ha e).
      apply sorted_head.
      apply unif_part_sort.
      by apply Rlt_le.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite size_mkseq.
      eapply lt_trans ; apply lt_n_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply unif_part_sort, Rlt_le.
      intros x y Hxy.
      lra.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_size_f2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite size_mkseq.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_n_Sn.
      apply ptd_f2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply unif_part_sort, Rlt_le.
      intros x y Hxy.
      lra.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_size_f2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite size_mkseq.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_n_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite SF_lx_f2 ; try by apply lt_O_Sn.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite {2}(Hb e).
      apply Req_le.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite (last_unzip1 _ 0).
      fold (SF_last 0 (s e)).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_last_lx SF_lx_f2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by rewrite (last_nth 0) size_mkseq.
      apply lt_O_Sn.
      apply Rle_lt_trans with (norm (minus (nth 0 (unif_part a b (n e)) (S (n e)))
      (nth 0 (unif_part a b (n e)) (n e)))).
      change norm with Rabs.
      apply Rabs_le_between ; rewrite Rabs_pos_eq.
      change minus with Rminus ; rewrite Ropp_minus_distr'.
      cut (nth 0 (unif_part a b (n e)) (n e) <= nth 0 (SF_ly (s e)) (n e) <= nth 0 (unif_part a b (n e)) (S (n e))).
        lra.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_ly_f2 nth_behead (nth_pairmap 0).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      move: {-2 4}(S (n e)) Hi => Si /= ; clear ; lra.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite size_mkseq.
      apply SSR_leq, le_refl.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      apply -> Rminus_le_0.
      apply (sorted_nth Rle (unif_part a b (n e))).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply unif_part_sort, Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq ; by apply lt_n_Sn.
      eapply Rle_lt_trans.
      apply nth_le_seq_step.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq ; by apply lt_n_Sn.
      apply (proj2_sig (seq_step_unif_part_ex a b (proj1_sig (H e)))).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SSR_leq.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_size_ly.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      apply le_S_n ; rewrite -SF_size_lx.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite SF_lx_f2.
(* Goal: Rle b (@last R (@SF_h R ptd) (@unzip1 R R (@SF_t R ptd))) *)
      rewrite size_mkseq ; by apply le_refl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply lt_O_Sn.
(* Goal: Rle b (@last R (@SF_h R ptd) (@unzip1 R R (@SF_t R ptd))) *)
    rewrite minus_eq_zero norm_zero ; by apply e.
(* Goal: Rle b (@last R (@SF_h R ptd) (@unzip1 R R (@SF_t R ptd))) *)
    rewrite minus_eq_zero norm_zero ; by apply e.
(* Goal: ex_RInt g a b *)
  now exists If.
Qed.

(** ** Norm *)

Section norm_RInt.

Context {V : NormedModule R_AbsRing}.

Lemma norm_RInt_le :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (g : R -> R) (a b : R) (lf : V) (lg : R),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a <= b ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x, a <= x <= b -> norm (f x) <= g x) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b lf ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt g a b lg ->
  norm lf <= lg.
Proof.
  intros f g a b lf lg Hab H Hf Hg.
  change (Rbar_le (norm lf) lg).
  apply (filterlim_le (F := Riemann_fine a b)) with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (fun ptd : SF_seq => norm (scal (sign (b - a)) (Riemann_sum f ptd)))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (fun ptd : SF_seq => scal (sign (b - a)) (Riemann_sum g ptd)).
  3: apply Hg.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  exists (mkposreal _ Rlt_0_1) => ptd _ [Hptd [Hh Hl]].
  destruct Hab as [Hab|Hab].
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  rewrite -> sign_eq_1 by exact: Rlt_Rminus.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !scal_one.
  apply Riemann_sum_norm.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => t.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite Hl Hh /Rmin /Rmax ; case: Rle_dec => [_|].
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
  apply H.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => /Rnot_le_lt Hab'.
  elim (Rlt_not_le _ _ Hab).
  now apply Rlt_le.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -> Rminus_diag_eq by now apply sym_eq.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite sign_0.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite 2!scal_zero_l.
(* Goal: Rle b (@last R (@SF_h R ptd) (@unzip1 R R (@SF_t R ptd))) *)
  rewrite norm_zero ; by right.
  apply filterlim_comp with (locally lf).
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  by apply Hf.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply filterlim_norm.
Qed.

Lemma norm_RInt_le_const :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a b : R) (lf : V) (M : R),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a <= b ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x, a <= x <= b -> norm (f x) <= M) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b lf ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  norm lf <= (b - a) * M.
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (lf : NormedModule.sort R_AbsRing V) (M : R) (_ : Rle a b) (_ : forall (x : R) (_ : and (Rle a x) (Rle x b)), Rle (@norm R_AbsRing V (f x)) M) (_ : @is_RInt V f a b lf), Rle (@norm R_AbsRing V lf) (Rmult (Rminus b a) M) *)
intros f a b lf M Hab H Hf.
(* Goal: Rle (@norm R_AbsRing V lf) (Rmult (Rminus b a) M) *)
apply norm_RInt_le with (1 := Hab) (2 := H) (3 := Hf).
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: is_RInt_const.
Qed.

Lemma norm_RInt_le_const_abs :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> V) (a b : R) (lf : V) (M : R),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x, Rmin a b <= x <= Rmax a b -> norm (f x) <= M) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b lf ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  norm lf <= Rabs (b - a) * M.
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (lf : NormedModule.sort R_AbsRing V) (M : R) (_ : forall (x : R) (_ : and (Rle (Rmin a b) x) (Rle x (Rmax a b))), Rle (@norm R_AbsRing V (f x)) M) (_ : @is_RInt V f a b lf), Rle (@norm R_AbsRing V lf) (Rmult (Rabs (Rminus b a)) M) *)
intros f a b lf M H Hf.
(* Goal: Rle (@norm R_AbsRing V lf) (Rmult (Rabs (Rminus b a)) M) *)
unfold Rabs.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
case Rcase_abs => Hab.
(* Goal: Rle (@norm R_AbsRing V lf) (Rmult (Ropp (Rminus b a)) M) *)
(* Goal: Rle (@norm R_AbsRing V lf) (Rmult (Rminus b a) M) *)
apply Rminus_lt in Hab.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Ropp_minus_distr.
(* Goal: Rle (@norm R_AbsRing V lf) (Rmult (Rminus a b) M) *)
(* Goal: Rle (@norm R_AbsRing V lf) (Rmult (Rminus b a) M) *)
apply is_RInt_swap in Hf.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
rewrite <- norm_opp.
(* Goal: Rle (@norm R_AbsRing V (@opp (NormedModule.AbelianGroup R_AbsRing V) lf)) (Rmult (Rminus a b) M) *)
(* Goal: Rle (@norm R_AbsRing V lf) (Rmult (Rminus b a) M) *)
apply norm_RInt_le_const with (3 := Hf).
now apply Rlt_le.
(* Goal: forall (x : R) (_ : and (Rlt a x) (Rlt x b)), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
intros x Hx.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
apply H.
now rewrite -> Rmin_right, Rmax_left by now apply Rlt_le.
(* Goal: Rle (@norm R_AbsRing V lf) (Rmult (Rminus b a) M) *)
apply Rminus_ge in Hab.
(* Goal: Rle (@norm R_AbsRing V lf) (Rmult (Rminus b a) M) *)
apply Rge_le in Hab.
(* Goal: Rle (@norm R_AbsRing V lf) (Rmult (Rminus b a) M) *)
apply norm_RInt_le_const with (1 := Hab) (3 := Hf).
(* Goal: forall (x : R) (_ : and (Rlt a x) (Rlt x b)), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
intros x Hx.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
apply H.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
now rewrite -> Rmin_left, Rmax_right.
Qed.

End norm_RInt.

(** * Specific Normed Modules *)

(** Pairs *)

Section prod.

Context {U V : NormedModule R_AbsRing}.

Lemma is_RInt_fct_extend_fst
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (f : R -> U * V) (a b : R) (l : U * V) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b l -> is_RInt (fun t => fst (f t)) a b (fst l).
Proof.
(* Goal: forall _ : @is_RInt (prod_NormedModule R_AbsRing U V) f a b l, @is_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b (@snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) l) *)
  intros Hf P [eP HP].
(* Goal: @filtermap (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing U)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing U) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd)) (Riemann_fine a b) P *)
  destruct (Hf (fun u : U * V => P (fst u))) as [ef Hf'].
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    exists eP => y Hy.
(* Goal: P (@snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) y) *)
(* Goal: @filtermap (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd)) (Riemann_fine a b) P *)
    apply HP.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing V) (@snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) l) (pos eP) (@snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) y) *)
(* Goal: @filtermap (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd)) (Riemann_fine a b) P *)
    apply Hy.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  exists ef => y H1 H2.
  replace (Riemann_sum (fun t : R => fst (f t)) y)
    with (fst (Riemann_sum f y)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hf'.
(* Goal: @eq (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@snd (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing U)) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (prod_ModuleSpace R_Ring (NormedModule.ModuleSpace R_AbsRing U) (NormedModule.ModuleSpace R_AbsRing V)) f y)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) y) *)
  clear.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := y) => {y} [x0 | [x1 y0] y IH].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite /Riemann_sum /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite ?Riemann_sum_cons /= IH.
Qed.

Lemma is_RInt_fct_extend_snd
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (f : R -> U * V) (a b : R) (l : U * V) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b l -> is_RInt (fun t => snd (f t)) a b (snd l).
Proof.
(* Goal: forall _ : @is_RInt (prod_NormedModule R_AbsRing U V) f a b l, @is_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b (@snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) l) *)
  intros Hf P [eP HP].
(* Goal: @filtermap (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd)) (Riemann_fine a b) P *)
  destruct (Hf (fun u : U * V => P (snd u))) as [ef Hf'].
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    exists eP => y Hy.
(* Goal: P (@snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) y) *)
(* Goal: @filtermap (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd)) (Riemann_fine a b) P *)
    apply HP.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing V) (@snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) l) (pos eP) (@snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) y) *)
(* Goal: @filtermap (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd)) (Riemann_fine a b) P *)
    apply Hy.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  exists ef => y H1 H2.
  replace (Riemann_sum (fun t : R => snd (f t)) y)
    with (snd (Riemann_sum f y)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hf'.
(* Goal: @eq (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@snd (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing U)) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (prod_ModuleSpace R_Ring (NormedModule.ModuleSpace R_AbsRing U) (NormedModule.ModuleSpace R_AbsRing V)) f y)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) y) *)
  clear.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := y) => {y} [x0 | [x1 y0] y IH].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite /Riemann_sum /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite ?Riemann_sum_cons /= IH.
Qed.

Lemma is_RInt_fct_extend_pair
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (f : R -> U * V) (a b : R) lu lv :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt (fun t => fst (f t)) a b lu ->
  is_RInt (fun t => snd (f t)) a b lv
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    -> is_RInt f a b (lu,lv).
Proof.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => H1 H2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply filterlim_locally => eps.
(* Goal: Riemann_fine a b (fun x : @SF_seq R => @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) f x))) *)
  generalize (proj1 (filterlim_locally _ _) H1 eps) => {H1} ; intros [d1 H1].
(* Goal: Riemann_fine a b (fun x : @SF_seq R => @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) f x))) *)
  generalize (proj1 (filterlim_locally _ _) H2 eps) => {H2} ; intros [d2 H2].
(* Goal: Riemann_fine a b (fun x : @SF_seq R => @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) f x))) *)
  simpl in H1, H2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  exists (mkposreal _ (Rmin_stable_in_posreal d1 d2)) => /= ptd Hstep Hptd.
  rewrite (Riemann_sum_pair f ptd) ; simpl.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply H1 => //.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le_trans with (2 := Rmin_l d1 d2).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply H2 => //.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le_trans with (2 := Rmin_r d1 d2).
Qed.

Lemma ex_RInt_fct_extend_fst
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (f : R -> U * V) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b -> ex_RInt (fun t => fst (f t)) a b.
Proof.
(* Goal: forall _ : @ex_RInt (prod_NormedModule R_AbsRing U V) f a b, @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b *)
  intros [l Hl].
(* Goal: @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b *)
  exists (fst l).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply is_RInt_fct_extend_fst.
Qed.

Lemma ex_RInt_fct_extend_snd
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (f : R -> U * V) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b -> ex_RInt (fun t => snd (f t)) a b.
Proof.
(* Goal: forall _ : @ex_RInt (prod_NormedModule R_AbsRing U V) f a b, @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b *)
  intros [l Hl].
(* Goal: @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b *)
  exists (snd l).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply is_RInt_fct_extend_snd.
Qed.

Lemma ex_RInt_fct_extend_pair
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (f : R -> U * V) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt (fun t => fst (f t)) a b ->
  ex_RInt (fun t => snd (f t)) a b
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    -> ex_RInt f a b.
Proof.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => [l1 H1] [l2 H2].
(* Goal: @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  exists (l1,l2).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply is_RInt_fct_extend_pair.
Qed.

Lemma RInt_fct_extend_pair
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
   (U_RInt : (R -> U) -> R -> R -> U) (V_RInt : (R -> V) -> R -> R -> V) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall f a b l, is_RInt f a b l -> U_RInt f a b = l)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  -> (forall f a b l, is_RInt f a b l -> V_RInt f a b = l)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  -> forall f a b l, is_RInt f a b l
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    -> (U_RInt (fun t => fst (f t)) a b, V_RInt (fun t => snd (f t)) a b) = l.
Proof.
(* Goal: forall (_ : forall (f : forall _ : R, NormedModule.sort R_AbsRing U) (a b : R) (l : NormedModule.sort R_AbsRing U) (_ : @is_RInt U f a b l), @eq (NormedModule.sort R_AbsRing U) (U_RInt f a b) l) (_ : forall (f : forall _ : R, NormedModule.sort R_AbsRing V) (a b : R) (l : NormedModule.sort R_AbsRing V) (_ : @is_RInt V f a b l), @eq (NormedModule.sort R_AbsRing V) (V_RInt f a b) l) (f : forall _ : R, NormedModule.sort R_AbsRing (prod_NormedModule R_AbsRing U V)) (a b : R) (l : NormedModule.sort R_AbsRing (prod_NormedModule R_AbsRing U V)) (_ : @is_RInt (prod_NormedModule R_AbsRing U V) f a b l), @eq (prod (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (U_RInt (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (V_RInt (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b)) l *)
  intros HU HV f a b l Hf.
  apply injective_projections ; simpl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply HU ; by apply is_RInt_fct_extend_fst.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply HV ; by apply is_RInt_fct_extend_snd.
Qed.

End prod.

(** * The total function [RInt] *)

Section RInt.

Context {V : CompleteNormedModule R_AbsRing}.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Definition RInt (f : R -> V) (a b : R) := iota (is_RInt f a b).

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma is_RInt_unique (f : R -> V) (a b : R) (l : V) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b l -> RInt f a b = l.
Proof.
(* Goal: forall _ : @is_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b l, @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing V)) (RInt f a b) l *)
apply iota_filterlim_locally.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_correct (f : R -> V) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b -> is_RInt f a b (RInt f a b).
Proof.
(* Goal: forall _ : @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b, @is_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b (RInt f a b) *)
intros [If HIf].
(* Goal: @is_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b (RInt f a b) *)
erewrite is_RInt_unique ; exact HIf.
Qed.

Lemma opp_RInt_swap :
  forall f a b,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b ->
  opp (RInt f a b) = RInt f b a.
Proof.
intros f a b [If HIf].
(* Goal: @eq (AbelianGroup.sort (CompleteNormedModule.AbelianGroup R_AbsRing V)) (@plus (CompleteNormedModule.AbelianGroup R_AbsRing V) (RInt f a b) (RInt f b c)) (RInt f a c) *)
apply sym_eq, is_RInt_unique.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: is_RInt_swap.
apply RInt_correct.
(* Goal: ex_RInt g a b *)
now exists If.
Qed.

(** Correction of RInt *)

(*
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma is_RInt_lim_seq (f : R -> R) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall If : R, is_RInt f a b If -> is_lim_seq (RInt_val f a b) If.
Proof.
  wlog: a b /(a < b) => [Hw | Hab] If Hex.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Rle_lt_dec a b) => Hab.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Hab => Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.

    Focus 2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    cut (is_lim_seq (RInt_val f b a) (-If)).
      intros H.
      apply is_lim_seq_spec in H.
      apply is_lim_seq_spec.
      move => eps ; case: (H eps) => {H} N H ; exists N => n Hn.
      rewrite RInt_val_swap.
      rewrite /opp /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      replace (- RInt_val f b a n - If) with (- (RInt_val f b a n - - If)) by ring.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
      rewrite Rabs_Ropp ; by apply H.
    apply Hw.
    exact: Hab.

    exact: is_RInt_swap.

    assert (forall n, RInt_val f a a n = 0).
      move => n ; by rewrite RInt_val_point.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite -Hab in Hex |- * => {Hab b}.
    replace If with 0.
    apply is_lim_seq_spec.
    move => eps ; exists O => n _.
    rewrite H.
    rewrite Rminus_0_r Rabs_R0 ; apply eps.
    suff H0 : forall eps : posreal, Rabs If < eps.
    apply Rle_antisym ; apply le_epsilon => e He ;
    set eps := mkposreal e He ; apply Rlt_le.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite -(Rminus_eq_0 If) ;
    apply Rplus_lt_compat_l, Rle_lt_trans with (Rabs If).
    exact: Rabs_maj2.
    by apply (H0 eps).
    rewrite Rplus_0_l ;
    apply Rle_lt_trans with (Rabs If).
    exact: Rle_abs.
    by apply (H0 eps).
    generalize (proj1 (filterlim_locally _ If) Hex).
    clear Hex.
    intros Hex.
    move => eps ; move: (Hex eps) => {Hex}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rminus_eq_0 sign_0.
    case => alpha Halpha.
    set ptd := @SF_nil R a.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    replace If with (If - 0 * Riemann_sum f ptd) by ring.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rabs_minus_sym.
    apply Halpha.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply alpha.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
    move => i /= Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_n_O in Hi.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
    rewrite /Rmin ; by case: Rle_dec (Rle_refl a).
    rewrite /Rmax ; by case: Rle_dec (Rle_refl a).
(* * Preuve dans la cas a < b *)
  apply is_lim_seq_spec.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => eps.
  generalize (proj1 (filterlim_locally _ If) Hex).
  clear Hex.
  intros Hex.
  case: (Hex eps) => {Hex} alpha Hex.
(* ** Trouver N *)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  have HN : 0 <= (b-a)/alpha.
    apply Rdiv_le_0_compat.
    apply -> Rminus_le_0 ; apply Rlt_le, Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply alpha.
  set N := (nfloor _ HN).
  exists N => n Hn.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Rabs_Ropp.
  set ptd := SF_seq_f2 (fun x y => (x+y)/2) (unif_part a b n).
(* ** Appliquer Hex *)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (- (RInt_val f a b n - If))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    with (If - sign (b - a) * Riemann_sum f ptd).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rabs_minus_sym.
  apply: Hex.
  apply Rle_lt_trans with ((b-a)/(INR n + 1)).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  suff : forall i, (S i < size (SF_lx ptd))%nat ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    nth 0 (SF_lx ptd) (S i) - nth 0 (SF_lx ptd) i = (b-a)/(INR n + 1).
  elim: (SF_lx ptd) => /= [ | x0].
  move => _ ; apply Rdiv_le_0_compat ;
  [ by apply Rlt_le, Rgt_minus | by apply INRp1_pos].
  case => /=[ | x1 s] IH Hs.
  apply Rdiv_le_0_compat ;
  [ by apply Rlt_le, Rgt_minus | by apply INRp1_pos].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (seq_step _) with (Rmax (Rabs (x1 - x0)) (seq_step (x1::s))) by auto.
  rewrite (Hs _ (lt_n_S _ _ (lt_O_Sn _))) Rabs_right.
  apply Rmax_lub.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  by apply Rle_refl.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply IH => i Hi.
  by apply (Hs _ (lt_n_S _ _ Hi)).
  apply Rle_ge, Rdiv_le_0_compat ;
  [ by apply Rlt_le, Rgt_minus | by apply INRp1_pos].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_lx_f2.
  replace (head 0%R (unif_part a b n) :: behead (unif_part a b n))
    with (unif_part a b n) by auto.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite size_mkseq => i Hi ; rewrite !nth_mkseq ?S_INR.
  field ; apply Rgt_not_eq, INRp1_pos.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply SSR_leq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply SSR_leq ; by intuition.
  eapply lt_O_Sn.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rle_lt_trans with ((b-a)/(INR N + 1)).
(* Goal: Rle (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing R_NormedModule) f' ptd)) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  apply Rmult_le_compat_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rgt_minus.
  apply Rinv_le_contravar.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply INRp1_pos.
  by apply Rplus_le_compat_r, le_INR.
  apply Rlt_div_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply INRp1_pos.
  rewrite Rmult_comm ; apply Rlt_div_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply alpha.
  rewrite /N /nfloor ; case: nfloor_ex => N' HN' /=.
  by apply HN'.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => i.
  rewrite SF_size_f2 size_mkseq => Hi ; simpl in Hi.
  rewrite SF_ly_f2 SF_lx_f2.
  2: apply lt_O_Sn.
  replace (head 0 (unif_part a b n) :: behead (unif_part a b n)) with
    (unif_part a b n) by auto.
  rewrite nth_behead (nth_pairmap 0).
  replace (nth 0 (0 :: unif_part a b n) (S i)) with
    (nth 0 (unif_part a b n) i) by auto.
  have : nth 0 (unif_part a b n) i <= nth 0 (unif_part a b n) (S i).
    apply (sorted_nth Rle).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply unif_part_sort, Rlt_le.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    by rewrite size_mkseq.
  move : (nth 0 (unif_part a b n) i) (nth 0 (unif_part a b n) (S i)) => x y Hxy.
  lra.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply SSR_leq ; rewrite size_mkseq ; by intuition.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  rewrite /Rmin /= ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
  field ; apply Rgt_not_eq, INRp1_pos.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -nth_last SF_lx_f2.
  2: apply lt_O_Sn.
  rewrite size_mkseq nth_mkseq ?S_INR /=.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /Rmax ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
  field ; apply Rgt_not_eq, INRp1_pos.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Ropp_minus_distr'.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  rewrite -> sign_eq_1 by exact: Rlt_Rminus.
  rewrite Rmult_1_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
Qed.
*)

(** ** Usual rewritings *)

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_ext (f g : R -> V) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x, Rmin a b < x < Rmax a b -> f x = g x) ->
  RInt f a b = RInt g a b.
Proof.
(* Goal: forall _ : forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (CompleteNormedModule.sort R_AbsRing V) (f x) (g x), @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing V)) (RInt f a b) (RInt g a b) *)
intros Hfg.
(* Goal: @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing V)) (RInt f a b) (RInt g a b) *)
apply eq_close.
(* Goal: @close (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing V)) (RInt f a b) (RInt g a b) *)
apply: close_iota ; split ; apply is_RInt_ext.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing V)) (f x) (g x) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing V)) (g x) (f x) *)
exact Hfg.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing V)) (g x) (f x) *)
intros t Ht.
(* Goal: @eq (NormedModule.sort R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing V)) (g t) (f t) *)
now apply sym_eq, Hfg.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_point (a : R) (f : R -> V) :
  RInt f a a = zero.
Proof.
(* Goal: @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing R_CompleteNormedModule)) (@RInt R_CompleteNormedModule f a b) (@RiemannInt f a b pr) *)
apply is_RInt_unique.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
exact: is_RInt_point.
Qed.

Lemma RInt_const (a b : R) (c : V) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  RInt (fun _ => c) a b = scal (b - a) c.
Proof.
(* Goal: @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing R_CompleteNormedModule)) (@RInt R_CompleteNormedModule f a b) (@RiemannInt f a b pr) *)
apply is_RInt_unique.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
exact: is_RInt_const.
Qed.

(*
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_comp_opp (f : R -> V) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f (-a) (-b) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  RInt (fun y => f (- y)) a b = opp (RInt f (-a) (-b)).
Proof.
intros Hf.
(* Goal: @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing R_CompleteNormedModule)) (@RInt R_CompleteNormedModule f a b) (@RiemannInt f a b pr) *)
apply is_RInt_unique.
apply: is_RInt_comp_opp.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  case: (Req_dec a b) => [<- {b} | Hab].
  by rewrite ?RInt_point.
  wlog: a b Hab / (a < b) => [Hw | {Hab} Hab].
    case: (Rle_lt_dec a b) => Hab'.
    case: Hab' => // Hab'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite -(RInt_swap _ b) -(RInt_swap _ (-b)).
    rewrite Hw => //.
    by apply Rlt_not_eq.
  rewrite /RInt.
  case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
  case: Rle_dec (Rlt_not_le _ _ (Ropp_lt_contravar _ _ Hab)) => // _ _.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Rbar_opp_real.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Lim_seq_opp.
  apply Lim_seq_ext => n.
  rewrite RInt_val_swap /RInt_val Riemann_sum_opp.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  simpl opp ; apply f_equal.
  rewrite Riemann_sum_map SF_map_f2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (unif_part (- b) (- a) n) with (map Ropp (unif_part b a n)).
Focus 2.
apply eq_from_nth with 0.
by rewrite size_map !size_mkseq.
rewrite size_map !size_mkseq => i Hi.
rewrite (nth_map 0 0).
rewrite ?(nth_mkseq 0) => //.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
field ; rewrite -S_INR ; apply not_0_INR, sym_not_eq, O_S.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
by rewrite size_mkseq.
elim: (unif_part b a n) => /= [ | x0 s IH].
rewrite /Riemann_sum /=.
apply opp_zero.
destruct s as [ | x1 s].
rewrite /Riemann_sum /=.
apply opp_zero.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
rewrite (SF_cons_f2 _ (- x0)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
2: by apply lt_O_Sn.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Riemann_sum_cons /=.
rewrite (SF_cons_f2 _ (x0)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
2: by apply lt_O_Sn.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Riemann_sum_cons /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
rewrite -IH /opp /plus /= Ropp_plus_distr.
apply f_equal2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
replace (- ((x0 + x1) / 2)) with ((- x0 + - x1) / 2) by field.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite /scal /= /mult /=.
ring.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
apply f_equal.
(* Goal: @eq (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@snd (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing U)) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (prod_ModuleSpace R_Ring (NormedModule.ModuleSpace R_AbsRing U) (NormedModule.ModuleSpace R_AbsRing V)) f y)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) y) *)
clear.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
by [].
Qed.
*)

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_comp_lin (f : R -> V) (u v a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f (u * a + v) (u * b + v) ->
  RInt (fun y => scal u (f (u * y + v))) a b = RInt f (u * a + v) (u * b + v).
Proof.
intros Hf.
(* Goal: @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing R_CompleteNormedModule)) (@RInt R_CompleteNormedModule f a b) (@RiemannInt f a b pr) *)
apply is_RInt_unique.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: is_RInt_comp_lin.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
exact: RInt_correct.
Qed.

Lemma RInt_Chasles :
  forall f a b c,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b -> ex_RInt f b c ->
  plus (RInt f a b) (RInt f b c) = RInt f a c.
Proof.
(* Goal: forall (f : forall _ : R, NormedModule.sort R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing V)) (a b c : R) (_ : @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b) (_ : @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f b c), @eq (AbelianGroup.sort (CompleteNormedModule.AbelianGroup R_AbsRing V)) (@plus (CompleteNormedModule.AbelianGroup R_AbsRing V) (RInt f a b) (RInt f b c)) (RInt f a c) *)
intros f a b c H1 H2.
(* Goal: @eq (AbelianGroup.sort (CompleteNormedModule.AbelianGroup R_AbsRing V)) (@plus (CompleteNormedModule.AbelianGroup R_AbsRing V) (RInt f a b) (RInt f b c)) (RInt f a c) *)
apply sym_eq, is_RInt_unique.
apply: is_RInt_Chasles ;
  now apply RInt_correct.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_scal (f : R -> V) (a b l : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b ->
  RInt (fun x => scal l (f x)) a b = scal l (RInt f a b).
Proof.
intros Hf.
(* Goal: @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing R_CompleteNormedModule)) (@RInt R_CompleteNormedModule f a b) (@RiemannInt f a b pr) *)
apply is_RInt_unique.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: is_RInt_scal.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
exact: RInt_correct.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_opp (f : R -> V) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b ->
  RInt (fun x => opp (f x)) a b = opp (RInt f a b).
Proof.
intros Hf.
(* Goal: @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing R_CompleteNormedModule)) (@RInt R_CompleteNormedModule f a b) (@RiemannInt f a b pr) *)
apply is_RInt_unique.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: is_RInt_opp.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
exact: RInt_correct.
Qed.

Lemma RInt_plus :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall f g a b, ex_RInt f a b -> ex_RInt g a b ->
  RInt (fun x => plus (f x) (g x)) a b = plus (RInt f a b) (RInt g a b).
Proof.
(* Goal: forall (f g : forall _ : R, NormedModule.sort R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing V)) (a b : R) (_ : @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b) (_ : @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) g a b), @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing V)) (RInt (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing V)) (f x) (g x)) a b) (@minus (CompleteNormedModule.AbelianGroup R_AbsRing V) (RInt f a b) (RInt g a b)) *)
intros f g a b Hf Hg.
(* Goal: @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing R_CompleteNormedModule)) (@RInt R_CompleteNormedModule f a b) (@RiemannInt f a b pr) *)
apply is_RInt_unique.
apply: is_RInt_plus ;
  now apply RInt_correct.
Qed.

Lemma RInt_minus :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall f g a b, ex_RInt f a b -> ex_RInt g a b ->
  RInt (fun x => minus (f x) (g x)) a b = minus (RInt f a b) (RInt g a b).
Proof.
(* Goal: forall (f g : forall _ : R, NormedModule.sort R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing V)) (a b : R) (_ : @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) f a b) (_ : @ex_RInt (CompleteNormedModule.NormedModule R_AbsRing V) g a b), @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing V)) (RInt (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing V)) (f x) (g x)) a b) (@minus (CompleteNormedModule.AbelianGroup R_AbsRing V) (RInt f a b) (RInt g a b)) *)
intros f g a b Hf Hg.
(* Goal: @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing R_CompleteNormedModule)) (@RInt R_CompleteNormedModule f a b) (@RiemannInt f a b pr) *)
apply is_RInt_unique.
apply: is_RInt_minus ;
  now apply RInt_correct.
Qed.

End RInt.

(** ** Order *)

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma is_RInt_ge_0 (f : R -> R) (a b If : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a <= b -> is_RInt f a b If ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x, a < x < b -> 0 <= f x) -> 0 <= If.
Proof.
(* Goal: forall (_ : Rle a b) (_ : @is_RInt R_NormedModule f a b If) (_ : forall (x : R) (_ : and (Rlt a x) (Rlt x b)), Rle (IZR Z0) (f x)), Rle (IZR Z0) If *)
intros Hab HIf Hf.
(* Goal: Rle (IZR Z0) If *)
set (f' := fun x => if Rle_dec x a then 0 else if Rle_dec b x then 0 else f x).
(* Goal: Rle (IZR Z0) If *)
apply is_RInt_ext with (g := f') in HIf.
(* Goal: Rle (IZR Z0) If *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
apply closed_filterlim_loc with (1 := HIf) (3 := closed_ge 0).
(* Goal: Riemann_fine a b (fun x : @SF_seq R => Rle (IZR Z0) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing R_NormedModule) f' x))) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
unfold Riemann_fine, within.
(* Goal: @locally_dist (@SF_seq R) (fun ptd : @SF_seq R => seq_step (@SF_lx R ptd)) (fun x : @SF_seq R => forall _ : and (pointed_subdiv x) (and (@eq R (@SF_h R x) (Rmin a b)) (@eq R (@last R (@SF_h R x) (@SF_lx R x)) (Rmax a b))), Rle (IZR Z0) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing R_NormedModule) f' x))) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
apply filter_forall.
(* Goal: forall (x : @SF_seq R) (_ : and (pointed_subdiv x) (and (@eq R (@SF_h R x) (Rmin a b)) (@eq R (@last R (@SF_h R x) (@SF_lx R x)) (Rmax a b)))), Rle (IZR Z0) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing R_NormedModule) f' x)) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
intros ptd Hptd.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
replace 0 with (scal (sign (b - a)) (Riemann_sum (fun _ => 0) ptd)).
(* Goal: Rle (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing R_NormedModule) f' ptd)) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
apply Rmult_le_compat_l.
(* Goal: Rle (IZR Z0) (sign (Rminus b a)) *)
(* Goal: Rle (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing R_NormedModule) f' ptd) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
apply sign_ge_0.
(* Goal: Rle (IZR Z0) (Rminus b a) *)
(* Goal: Rle (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing R_NormedModule) f' ptd) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
now apply Rge_le, Rge_minus, Rle_ge.
(* Goal: Rle (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing R_NormedModule) f' ptd) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
apply Riemann_sum_le.
(* Goal: pointed_subdiv ptd *)
(* Goal: forall (t : R) (_ : and (Rle (@SF_h R ptd) t) (Rle t (@last R (@SF_h R ptd) (@SF_lx R ptd)))), Rle (IZR Z0) (f' t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
apply Hptd.
(* Goal: forall (t : R) (_ : and (Rle (@SF_h R ptd) t) (Rle t (@last R (@SF_h R ptd) (@SF_lx R ptd)))), Rle (IZR Z0) (f' t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
intros t _.
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
unfold f'.
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (if @is_left (Rle x a) (not (Rle x a)) (Rle_dec x a) then IZR Z0 else if @is_left (Rle b x) (not (Rle b x)) (Rle_dec b x) then IZR Z0 else f x) *)
case Rle_dec as [H1|H1].
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
apply Rle_refl.
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (if @is_left (Rle x a) (not (Rle x a)) (@right (Rle x a) (not (Rle x a)) H1) then IZR Z0 else if @is_left (Rle b x) (not (Rle b x)) (Rle_dec b x) then IZR Z0 else f x) *)
case Rle_dec as [H2|H2].
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
apply Rle_refl.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
apply Hf.
(* Goal: and (Rlt a t) (Rlt t b) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
now split; apply Rnot_le_lt.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite Riemann_sum_const.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
by rewrite !scal_zero_r.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
rewrite (Rmin_left _ _ Hab) (Rmax_right _ _ Hab).
(* Goal: forall (x : R) (_ : and (Rlt a x) (Rlt x b)), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
intros x Hx.
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
unfold f'.
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (if @is_left (Rle x a) (not (Rle x a)) (Rle_dec x a) then IZR Z0 else if @is_left (Rle b x) (not (Rle b x)) (Rle_dec b x) then IZR Z0 else f x) *)
case Rle_dec as [H1|H1].
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (if @is_left (Rle x a) (not (Rle x a)) (@left (Rle x a) (not (Rle x a)) H1) then IZR Z0 else if @is_left (Rle b x) (not (Rle b x)) (Rle_dec b x) then IZR Z0 else f x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (if @is_left (Rle x a) (not (Rle x a)) (@right (Rle x a) (not (Rle x a)) H1) then IZR Z0 else if @is_left (Rle b x) (not (Rle b x)) (Rle_dec b x) then IZR Z0 else f x) *)
now elim (Rle_not_lt _ _ H1).
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (if @is_left (Rle x a) (not (Rle x a)) (@right (Rle x a) (not (Rle x a)) H1) then IZR Z0 else if @is_left (Rle b x) (not (Rle b x)) (Rle_dec b x) then IZR Z0 else f x) *)
case Rle_dec as [H2|H2].
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (if @is_left (Rle x a) (not (Rle x a)) (@right (Rle x a) (not (Rle x a)) H1) then IZR Z0 else if @is_left (Rle b x) (not (Rle b x)) (@left (Rle b x) (not (Rle b x)) H2) then IZR Z0 else f x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (if @is_left (Rle x a) (not (Rle x a)) (@right (Rle x a) (not (Rle x a)) H1) then IZR Z0 else if @is_left (Rle b x) (not (Rle b x)) (@right (Rle b x) (not (Rle b x)) H2) then IZR Z0 else f x) *)
now elim (Rle_not_lt _ _ H2).
(* Goal: @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (if @is_left (Rle x a) (not (Rle x a)) (@right (Rle x a) (not (Rle x a)) H1) then IZR Z0 else if @is_left (Rle b x) (not (Rle b x)) (@right (Rle b x) (not (Rle b x)) H2) then IZR Z0 else f x) *)
easy.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_ge_0 (f : R -> R) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a <= b -> ex_RInt f a b
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  -> (forall x, a < x < b -> 0 <= f x) -> 0 <= RInt f a b.
Proof.
(* Goal: forall (_ : Rle a b) (_ : @ex_RInt R_NormedModule f a b) (_ : forall (x : R) (_ : and (Rlt a x) (Rlt x b)), Rle (IZR Z0) (f x)), Rle (IZR Z0) (@RInt R_CompleteNormedModule f a b) *)
  intros Hab Hf Hpos.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: is_RInt_ge_0 Hab _ Hpos.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: RInt_correct.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma is_RInt_le (f g : R -> R) (a b If Ig : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a <= b ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_RInt f a b If -> is_RInt g a b Ig ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x, a < x < b -> f x <= g x) ->
  If <= Ig.
Proof.
(* Goal: forall (_ : Rle a b) (_ : @ex_RInt R_NormedModule f a b) (_ : @ex_RInt R_NormedModule g a b) (_ : forall (x : R) (_ : and (Rlt a x) (Rlt x b)), Rle (f x) (g x)), Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  intros Hab Hf Hg Hfg.
  apply Rminus_le_0.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: is_RInt_ge_0 Hab _ _.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: is_RInt_minus Hg Hf.
(* Goal: forall (x : R) (_ : and (Rlt a x) (Rlt x b)), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  intros x Hx.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply -> Rminus_le_0.
  apply Hfg, Hx.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_le (f g : R -> R) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a <= b ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b -> ex_RInt g a b->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x, a < x < b -> f x <= g x) ->
  RInt f a b <= RInt g a b.
Proof.
(* Goal: forall (_ : Rle a b) (_ : @ex_RInt R_NormedModule f a b) (_ : @ex_RInt R_NormedModule g a b) (_ : forall (x : R) (_ : and (Rlt a x) (Rlt x b)), Rle (f x) (g x)), Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  intros Hab Hf Hg Hfg.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: is_RInt_le Hab _ _ Hfg.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: RInt_correct.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: RInt_correct.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_gt_0 (g : R -> R) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (a < b) -> (forall x, a < x < b -> (0 < g x)) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x, a <= x <= b -> continuous g x) ->
  0 < RInt g a b.
Proof.
  intros Hab Hg Cg.
  set c := (a + b) / 2.
  assert (Hc : a < c < b).
    unfold c ; lra.
  assert (H : locally c (fun (x : R) => g c / 2 <= g x)).
    specialize (Hg _ Hc).
    specialize (Cg c (conj (Rlt_le _ _ (proj1 Hc)) (Rlt_le _ _ (proj2 Hc)))).
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (proj1 (filterlim_locally _ _) Cg (pos_div_2 (mkposreal _ Hg))) => /= d Hd.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    exists d => /= x Hx.
    specialize (Hd _ Hx).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /ball /= /AbsRing_ball in Hd.
    apply Rabs_lt_between' in Hd.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    field_simplify (g c - g c / 2) in Hd.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rlt_le, Hd.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  assert (Ig : ex_RInt g a b).
(* Goal: @ex_RInt R_NormedModule f a b *)
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    apply @ex_RInt_continuous.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rmin_left.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rmax_right.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
    intros.
(* Goal: @continuous R_UniformSpace (CompleteNormedModule.UniformSpace R_AbsRing R_CompleteNormedModule) g z *)
(* Goal: Rle a b *)
(* Goal: Rle a b *)
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    now apply Cg.
    by apply Rlt_le.
    by apply Rlt_le.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: H => /= d Hd.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  set a' := Rmax (c - d / 2) ((a + c) / 2).
  set b' := Rmin (c + d / 2) ((c + b) / 2).
  assert (Hab' : a' < b').
    apply Rlt_trans with c.
    apply Rmax_case.
    generalize (cond_pos d) ; lra.
    lra.
    apply Rmin_case.
    generalize (cond_pos d) ; lra.
    lra.
  assert (Ha' : a < a' < b).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
    eapply Rlt_le_trans, Rmax_r.
    lra.
    apply Rmax_case.
    generalize (cond_pos d) ; lra.
    lra.
  assert (Hb' : a < b' < b).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
    lra.
    eapply Rle_lt_trans.
    apply Rmin_r.
    lra.
  assert (ex_RInt g a a').
    eapply @ex_RInt_Chasles_1, Ig ; split ; by apply Rlt_le, Ha'.
  assert (ex_RInt g a' b).
    eapply @ex_RInt_Chasles_2, Ig ; split ; by apply Rlt_le, Ha'.
  assert (ex_RInt g a' b').
    eapply @ex_RInt_Chasles_1, H0 ; split => // ; apply Rlt_le => //.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hb'.
  assert (ex_RInt g b' b).
    eapply @ex_RInt_Chasles_2, H0 ; split => // ; apply Rlt_le => //.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hb'.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -(RInt_Chasles g a a' b) //.
  apply Rplus_le_lt_0_compat.
  apply (is_RInt_ge_0 g a a').
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Ha'.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: RInt_correct.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  intros ; apply Rlt_le, Hg ; split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply H3.
  eapply Rlt_trans, Ha'.
  apply H3.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -(RInt_Chasles g a' b' b) //.
  apply Rplus_lt_le_0_compat.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rlt_le_trans with ((b' - a') * (g c / 2)).
  specialize (Hg _ Hc).
  apply Rmult_lt_0_compat.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  by apply -> Rminus_lt_0.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply Rdiv_lt_0_compat => //.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_0_2.
  eapply is_RInt_le.
  apply Rlt_le, Hab'.
  apply @is_RInt_const.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: RInt_correct.
  intros ; apply Hd.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (double_var d).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  apply Rabs_lt_between' ; split.
  eapply Rlt_trans, H3.
  eapply Rlt_le_trans, Rmax_l.
(* Goal: Rlt (Rplus M2 (IZR (Zpos xH))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) *)
(* Goal: and (Rle a b) (Rle b c) *)
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rminus_lt_0 ; ring_simplify.
  by apply is_pos_div_2.
  eapply Rlt_trans.
  apply H3.
  eapply Rle_lt_trans.
  apply Rmin_l.
(* Goal: Rlt (Rplus M2 (IZR (Zpos xH))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))) *)
(* Goal: and (Rle a b) (Rle b c) *)
(* Goal: @eq R (Rmult (Rmult (IZR (Zpos (xO xH))) (pos (mkposreal (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) Hd3))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH))))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply Rminus_lt_0 ; ring_simplify.
  by apply is_pos_div_2.
  eapply is_RInt_ge_0.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  2: exact: RInt_correct.
  apply Rlt_le, Hb'.
  intros ; apply Rlt_le, Hg.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  eapply Rlt_trans, H3.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hb'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply H3.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_lt (f g : R -> R) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a < b ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x : R, a <= x <= b ->continuous g x) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x : R, a <= x <= b ->continuous f x) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall x : R, a < x < b -> f x < g x) ->
  RInt f a b < RInt g a b.
Proof.
(* Goal: forall (_ : Rlt a b) (_ : forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace g x) (_ : forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace f x) (_ : forall (x : R) (_ : and (Rlt a x) (Rlt x b)), Rlt (f x) (g x)), Rlt (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  intros Hab Cg Cf Hfg.
(* Goal: Rlt (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply Rminus_lt_0.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  assert (Ig : ex_RInt g a b).
(* Goal: @ex_RInt R_NormedModule f a b *)
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    apply @ex_RInt_continuous.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rmin_left.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rmax_right.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
    intros.
(* Goal: @continuous R_UniformSpace (CompleteNormedModule.UniformSpace R_AbsRing R_CompleteNormedModule) g z *)
(* Goal: Rle a b *)
(* Goal: Rle a b *)
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    now apply Cg.
    by apply Rlt_le.
    by apply Rlt_le.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  assert (ex_RInt f a b).
(* Goal: @ex_RInt R_NormedModule f a b *)
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    apply @ex_RInt_continuous.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rmin_left.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rmax_right.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
    intros.
(* Goal: @continuous R_UniformSpace (CompleteNormedModule.UniformSpace R_AbsRing R_CompleteNormedModule) f z *)
(* Goal: Rle a b *)
(* Goal: Rle a b *)
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    now apply Cf.
    by apply Rlt_le.
    by apply Rlt_le.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -[Rminus]/(@minus R_AbelianGroup) -RInt_minus //.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply RInt_gt_0 => //.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  now intros ; apply -> Rminus_lt_0 ; apply Hfg.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
  intros.
(* Goal: @continuous R_UniformSpace R_UniformSpace (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) x *)
  apply @continuous_minus.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Cg.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Cf.
Qed.

Lemma abs_RInt_le_const :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> R) a b M,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a <= b -> ex_RInt f a b ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  (forall t, a <= t <= b -> Rabs (f t) <= M) ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  Rabs (RInt f a b) <= (b - a) * M.
Proof.
intros f a b M Hab If H.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: (norm_RInt_le_const f) => //.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
exact: RInt_correct.
Qed.

(** * Equivalence with standard library *)

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma ex_RInt_Reals_aux_1 (f : R -> R) (a b : R) :
  forall pr : Riemann_integrable f a b,
    is_RInt f a b (RiemannInt pr).
Proof.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  wlog: a b / (a < b) => [Hw | Hab].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    case: (total_order_T a b) => [[Hab | <-] | Hab] pr.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite RiemannInt_P9.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
    apply: is_RInt_point.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (RiemannInt_P1 pr) => pr'.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite (RiemannInt_P8 pr pr').
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
    apply: is_RInt_swap.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    apply Hw => //.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /is_RInt.
(* Goal: forall pr : Riemann_integrable f a b, @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing R_CompleteNormedModule)) (@RInt R_CompleteNormedModule f a b) (@RiemannInt f a b pr) *)
  intros pr.
(* Goal: is_RInt f a a (@zero (NormedModule.AbelianGroup R_AbsRing V)) *)
  apply filterlim_locally.
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (@opp R_AbelianGroup (@one R_Ring)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus a b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing V) (@opp (Ring.AbelianGroup (AbsRing.Ring R_AbsRing)) (@one (AbsRing.Ring R_AbsRing))) If)) *)
  unfold Riemann_fine.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rmin_left.
  2: now apply Rlt_le.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rmax_right.
  2: now apply Rlt_le.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  rewrite -> sign_eq_1 by exact: Rlt_Rminus.

  cut (forall (phi : StepFun a b) (eps : posreal),
    exists alpha : posreal,
    forall ptd : SF_seq,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    pointed_subdiv ptd ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    seq_step (SF_lx ptd) < alpha ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    SF_h ptd = a ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    last (SF_h ptd) (unzip1 (SF_t ptd)) = b ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    Rabs (RiemannInt_SF phi - 1 * Riemann_sum phi ptd) <= eps).

  intros H.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /RiemannInt /= -/(Rminus _ _) => eps ; case: RiemannInt_exists => If HIf.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set eps2 := pos_div_2 eps.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set eps4 := pos_div_2 eps2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
(* RInt (f-phi) < eps/4 *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (HIf _ (cond_pos eps4)) => {HIf} N HIf.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (nfloor_ex (/eps4) (Rlt_le _ _ (Rinv_0_lt_compat _ (cond_pos eps4)))) => n Hn.
  move: (HIf (N+n)%nat (le_plus_l _ _)) => {HIf}.
  rewrite /phi_sequence /R_dist ; case: pr => phi [psi pr] ;
  simpl RiemannInt_SF => HIf.
(* RInt psi < eps/4*)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have H0 : Rabs (RiemannInt_SF psi) < eps4.
    apply Rlt_le_trans with (1 := proj2 pr).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite -(Rinv_involutive eps4 (Rgt_not_eq _ _ (cond_pos eps4))) /=.
    apply Rle_Rinv.
    apply Rinv_0_lt_compat, eps4.
    intuition.
    apply Rlt_le, Rlt_le_trans with (1 := proj2 Hn).
    apply Rplus_le_compat_r.
    apply le_INR, le_plus_r.
(* Rsum phi < eps/4 and Rsum psi < eps/4 *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (H phi eps4) => alpha0 Hphi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (H psi eps4) => {H} alpha1 Hpsi.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have Halpha : (0 < Rmin alpha0 alpha1).
    apply Rmin_case_strong => _ ; [apply alpha0 | apply alpha1].
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set alpha := mkposreal _ Halpha.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  exists alpha => ptd Hstep [Hsort [Ha Hb]].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (double_var eps) 1?(double_var (eps/2)) ?Rplus_assoc.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /ball /= /AbsRing_ball /= /abs /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rabs_minus_sym.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (_-_) with (-(RiemannInt_SF phi - If)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    + (RiemannInt_SF phi - Riemann_sum f ptd)) ;
    [ | rewrite /scal /= /mult /= ; by ring_simplify ].
  apply Rle_lt_trans with (1 := Rabs_triang _ _), Rplus_lt_le_compat.
  rewrite Rabs_Ropp ; apply HIf.
  clear HIf ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (_-_) with ((RiemannInt_SF phi - 1* Riemann_sum phi ptd)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    + (Riemann_sum phi ptd - Riemann_sum f ptd)) ;
    [ | by ring_simplify].
  apply Rle_trans with (1 := Rabs_triang _ _), Rplus_le_compat.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply Hphi => //.
  apply Rlt_le_trans with (1 := Hstep) ; rewrite /alpha ; apply Rmin_l.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Ropp_minus_distr' Rabs_Ropp.
  change Rminus with (@minus R_AbelianGroup).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Riemann_sum_minus.
  have H1 : (forall t : R,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    SF_h ptd <= t <= last (SF_h ptd) (SF_lx ptd) -> Rabs (f t - phi t) <= psi t).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move => t Ht.
    apply pr ; move: (Rlt_le _ _ Hab) ; rewrite /Rmin /Rmax ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    case: Rle_dec => // _ _ ; rewrite -Ha -Hb //.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rle_trans with (1 := Riemann_sum_norm (fun t => f t - phi t) _ _ Hsort H1).
  apply Rle_trans with (1 := Rle_abs _).
  replace (Riemann_sum psi ptd) with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (-(RiemannInt_SF psi - 1* Riemann_sum psi ptd)
    + RiemannInt_SF psi) ; [ | by ring_simplify].
  apply Rle_trans with (1 := Rabs_triang _ _), Rplus_le_compat.
  rewrite Rabs_Ropp ; apply Hpsi => //.
  apply Rlt_le_trans with (1 := Hstep) ; rewrite /alpha ; apply Rmin_r.
  apply Rlt_le, H0.

(* forall StepFun *)

  case => phi [lx [ly Hphi]] eps /= ;
  rewrite /RiemannInt_SF /subdivision /subdivision_val ;
  move: (Rlt_le _ _ Hab) ; case: Rle_dec => //= _ _.
  clear pr.
  move: (Rlt_le _ _ Hab) Hphi => {Hab} ;
  elim: lx ly eps a b => [ | lx0 lx IH] ly eps a b Hab.
(* lx = [::] *)
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  case ; intuition ; by [].
  case: lx IH ly => [ | lx1 lx] IH ;
  case => [ {IH} | ly0 ly] Had ; try by (case: Had ; intuition ; by []).
(* lx = [:: lx0] *)
  exists eps => ptd Hptd Hstep (*Hsort*) Ha Hb /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Riemann_sum_zero.
  rewrite Rmult_0_r Rminus_0_r Rabs_R0 ; apply Rlt_le, eps.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply ptd_sort.
  rewrite /SF_lx /= Hb Ha ; case: Had => {Ha Hb} _ [Ha [Hb _]] ; move: Ha Hb ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /Rmin /Rmax ; case: Rle_dec => // _ <- <- //.
(* lx = [:: lx0, lx1 & lx] *)
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set eps2 := pos_div_2 eps ; set eps4 := pos_div_2 eps2.
(* * alpha1 from IH *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (IH ly eps4 lx1 b) => {IH}.

  replace b with (last 0 (Rlist2seq (RList.cons lx0 (RList.cons lx1 lx)))).
  apply (sorted_last (Rlist2seq (RList.cons lx0 (RList.cons lx1 lx))) 1%nat)
  with (x0 := 0).
  apply sorted_compat ; rewrite seq2Rlist_bij ; apply Had.
  simpl ; apply lt_n_S, lt_O_Sn.
  case: Had => /= _ [_ [Hb _]] ; move: Hb ; rewrite /Rmax ;
  case : Rle_dec => //= _ ;
  elim: (lx) lx1  => //= h s IH _ ; apply IH.
  apply (StepFun_P7 Hab Had).

(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => /= alpha1 IH.
(* * alpha2 from H *)
  cut (forall eps : posreal,
    exists alpha : posreal,
    forall ptd : SF_seq,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    pointed_subdiv ptd ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    seq_step (SF_lx ptd) < alpha ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    SF_h ptd = a ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    last (SF_h ptd) (SF_lx ptd) = lx1 ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    Rabs (ly0 * (lx1 - lx0) - Riemann_sum phi ptd) <= eps).

  intros H.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (H eps4) => {H} alpha2 H.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
(* * alpha3 from (fmax - fmin) *)
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set fmin1 := foldr Rmin 0 (ly0::Rlist2seq ly).
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set fmin2 := foldr Rmin 0 (map phi (lx0::lx1::Rlist2seq lx)).
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set fmin := Rmin fmin1 fmin2.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set fmax1 := foldr Rmax 0 (ly0::Rlist2seq ly).
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set fmax2 := foldr Rmax 0 (map phi (lx0::lx1::Rlist2seq lx)).
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set fmax := Rmax fmax1 fmax2.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  have Ha3 : (0 < eps4 / (Rmax (fmax - fmin) 1)).
    apply Rdiv_lt_0_compat ; [ apply eps4 | ].
    apply Rlt_le_trans with (2 := RmaxLess2 _ _), Rlt_0_1.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set alpha3 := mkposreal _ Ha3.
(* * alpha = Rmin (Rmin alpha1 alpha2) alpha3 *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have Halpha : (0 < Rmin (Rmin alpha1 alpha2) alpha3).
    apply Rmin_case_strong => _ ; [ | apply alpha3].
    apply Rmin_case_strong => _ ; [ apply alpha1 | apply alpha2].
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set alpha := mkposreal _ Halpha.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  exists alpha => ptd Hptd Hstep Ha Hb.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  suff Hff : forall x, a <= x <= b -> fmin <= phi x <= fmax.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  suff Hab1 : forall i, (i <= SF_size ptd)%nat -> a <= nth 0 (SF_lx ptd) i <= b.
  suff Hab0 : a <= lx1 <= b.

(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (SF_Chasles _ _ lx1 (SF_h ptd)) /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (_-_) with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    ((ly0 * (lx1 - lx0) - 1* Riemann_sum phi (SF_cut_down' ptd lx1 (SF_h ptd)))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    + (Int_SF ly (RList.cons lx1 lx) - 1* Riemann_sum phi (SF_cut_up' ptd lx1 (SF_h ptd))))
    ; [ | rewrite /plus /= ; by ring_simplify].

  rewrite (double_var eps) ;
  apply Rle_trans with (1 := Rabs_triang _ _), Rplus_le_compat.

(* partie [lx0;lx1] *)

(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set ptd_r_last := (SF_last a (SF_cut_down' ptd lx1 a)).
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set ptd_r_belast := (SF_belast (SF_cut_down' ptd lx1 a)).
  set ptd_r := SF_rcons ptd_r_belast (lx1, (fst (SF_last a ptd_r_belast) + lx1)/2).

(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (H ptd_r) => {H} H.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (_-_) with ((ly0 * (lx1 - lx0) - Riemann_sum phi ptd_r) +
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (phi ((fst (SF_last 0 ptd_r_belast) + lx1)/2) - phi (snd ptd_r_last))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      * (lx1 - fst (SF_last 0 ptd_r_belast))).
  rewrite (double_var (eps/2)) ;
  apply Rle_trans with (1 := Rabs_triang _ _), Rplus_le_compat.

(* * appliquer H *)
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: H => {IH}.

  Focus 3.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite -Ha /ptd_r /ptd_r_belast.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    move: (proj1 Hab0) ; rewrite -Ha.
    apply SF_cons_dec with (s := ptd) => [x0 | [x0 y0] s] //= Hx0 ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by case: Rle_dec.
  Focus 3.
    revert ptd_r_belast ptd_r ; move: (proj1 Hab0) ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite -Ha ;
    apply SF_cons_ind with (s := ptd) => [x0 | [x0 y0] s IH]
    //= Hx0 ; case: Rle_dec => //= _.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by rewrite unzip1_rcons /= last_rcons.

(* ** ptd_r est une subdivision pointée *)

  revert ptd_r_belast ptd_r Hptd ;
  apply SF_cons_ind with (s := ptd) => /= [ x0 | [x0 y0] s IH ] Hptd.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_cut_down' /SF_belast /SF_last /SF_rcons /SF_ly /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -?(last_map (@fst R R)) -unzip1_fst /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?unzip2_rcons ?unzip1_rcons /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?unzip1_belast ?unzip2_belast /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?unzip1_behead ?unzip2_behead /=.

(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => /= [ _ | i Hi] .
  case: Rle_dec => //= Hx0 ; lra.
  contradict Hi ; apply le_not_lt.
  case: Rle_dec => //= Hx0 ; rewrite /SF_size /= ;
  apply le_n_S, le_O_n.

(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (IH (ptd_cons _ _ Hptd)) => {IH} IH.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => [ _ | i Hi].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_cut_down' /SF_belast /SF_last /SF_rcons /SF_ly /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -?(last_map (@fst R R)) -unzip1_fst /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?unzip2_rcons ?unzip1_rcons /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?unzip1_belast ?unzip2_belast /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?unzip1_behead ?unzip2_behead /=.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => //= Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => //= Hx1.
  move: Hptd Hx1 ; apply SF_cons_dec with (s := s)
    => {s IH} /= [x1 | [x1 y1] s] //= Hptd Hx1.
  by apply (Hptd O (lt_O_Sn _)).
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => //= Hx2.
  by apply (Hptd O (lt_O_Sn _)).
  by apply (Hptd O (lt_O_Sn _)).
  lra.
  lra.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hi (IH i) => {IH}.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite ?SF_size_rcons -?SF_size_lx ?SF_lx_rcons ?SF_ly_rcons.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_cut_down' /SF_belast /SF_last /SF_rcons /SF_ly /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -?(last_map (@fst R R)) -?unzip1_fst.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?unzip2_rcons ?unzip1_rcons /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?unzip1_belast ?unzip2_belast /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?unzip1_behead ?unzip2_behead /=.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s) lx1) => //= Hx1.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite size_belast size_belast'.
  move: Hx1 ;
  apply SF_cons_dec with (s := s) => {s Hptd} /= [ x1 | [x1 y1] s] //= Hx1.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => Hi IH ; apply IH ; by apply lt_S_n.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => //= Hx2.

(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => Hi IH ; apply IH ; by apply lt_S_n.

(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => Hi IH ; apply IH ; by apply lt_S_n.

(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => Hi ; by apply lt_S_n, lt_n_O in Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => Hi ; by apply lt_S_n, lt_n_O in Hi.

  apply Rlt_le_trans with (2 := Rmin_r alpha1 alpha2) ;
  apply Rlt_le_trans with (2 := Rmin_l _ alpha3).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply Rle_lt_trans with (2 := Hstep) => {Hstep}.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  move: Hab0 ; rewrite -Ha -Hb ;
  revert ptd_r_belast ptd_r => {Hab1} ;
  apply SF_cons_ind with (s := ptd) => /= [x0 | [x0 y0] s IH] //= Hab0.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_lx /SF_rcons /SF_belast /SF_last /SF_cut_down' /=.
  move: (proj1 Hab0) ; case: Rle_dec => //= _ _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (Rle_antisym _ _ (proj1 Hab0) (proj2 Hab0)) /seq_step /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  rewrite Rminus_eq_0 Rabs_R0 ; apply Rmax_case_strong ; by intuition.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hab0 (fun Hx1 => IH (conj Hx1 (proj2 Hab0))) => {IH}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s} /= [x1 | [x1 y1] s] //= Hab0 IH.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_cut_down' /SF_belast /SF_last /SF_rcons /SF_lx /=.
  move: (proj1 Hab0) ; case: (Rle_dec x0 lx1) => //= _ _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => //= Hx1.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /seq_step /=.
  apply Rle_max_compat_l.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (Rle_antisym _ _ Hx1 (proj2 Hab0)) Rminus_eq_0 Rabs_R0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply Rmax_case_strong ; by intuition.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /seq_step /=.
  apply Rle_max_compat_r.
  apply Rle_trans with (2 := Rle_abs _) ; rewrite Rabs_right.
  apply Rplus_le_compat_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rnot_le_lt.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rle_ge ; rewrite -Rminus_le_0 ; by apply Hab0.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  move: IH ; rewrite /SF_cut_down' /SF_belast /SF_last /SF_rcons /SF_lx /=.
  move: (proj1 Hab0) ; case: (Rle_dec x0 lx1) => //= _ _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1 IH.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (IH Hx1) => {IH}.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s) lx1) => //= Hx2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /seq_step -?(last_map (@fst R R)) /= => IH ;
  apply Rle_max_compat_l, IH.
  rewrite /seq_step /= ; apply Rle_max_compat_l.
  rewrite /seq_step /= ; apply Rmax_le_compat.
  apply Rle_trans with (2 := Rle_abs _) ; rewrite Rabs_right.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rplus_le_compat_r, Rlt_le, Rnot_le_lt, Hx1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rle_ge ; rewrite -Rminus_le_0 ; apply Hab0.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply Rmax_case_strong => _.
  apply Rabs_pos.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := s) => {s IH Hab0} /= [x2 | [x2 y2] s IH] //=.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Rle_refl.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply Rmax_case_strong => _.
  apply Rabs_pos.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: IH.
(* ** transition 1 *)
  clear H IH.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rle_trans with ((fmax - fmin) * alpha3).
  rewrite Rabs_mult ; apply Rmult_le_compat ; try apply Rabs_pos.
  apply Rabs_le_between.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Ropp_minus_distr'.
  suff H0 : a <= (fst (SF_last 0 ptd_r_belast) + lx1) / 2 <= b.
  suff H1 : a <= snd ptd_r_last <= b.
  split ; apply Rplus_le_compat, Ropp_le_contravar ;
  by apply Hff.
  revert ptd_r_last Hab1 Hptd.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := ptd) => /= [ x0 | [x0 y0] s IH] // Hab1 Hptd.
  rewrite /SF_cut_down' /= ; case: Rle_dec => //= ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by intuition.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_size_cons in Hab1.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (IH (fun i Hi => Hab1 (S i) (le_n_S _ _ Hi)) (ptd_cons _ _ Hptd)) => {IH}.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hptd (Hab1 O (le_O_n _)) (Hab1 1%nat (le_n_S _ _ (le_0_n _))) => {Hab1}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s Hab0} /= [ x1 | [x1 y1] s] //= Hptd Hx0 Hx1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /SF_cut_down' /SF_last /= -?(last_map (@snd R R)) -?unzip2_snd.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  move => _ ; split.
  apply Rle_trans with (1 := proj1 Hx0), (Hptd O (lt_O_Sn _)).
  apply Rle_trans with (2 := proj2 Hx1), (Hptd O (lt_O_Sn _)).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  move => _ ; split.
  apply Rle_trans with (1 := proj1 Hx0), (Hptd O (lt_O_Sn _)).
  apply Rle_trans with (2 := proj2 Hx1), (Hptd O (lt_O_Sn _)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => _ ; by intuition.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /SF_cut_down' /SF_last /= -?(last_map (@snd R R)) -?unzip2_snd.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec _ lx1) => //= Hx2'.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  move => _ ; split.
  apply Rle_trans with (1 := proj1 Hx0), (Hptd O (lt_O_Sn _)).
  apply Rle_trans with (2 := proj2 Hx1), (Hptd O (lt_O_Sn _)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => _ ; by intuition.

  cut (a <= fst (SF_last 0 ptd_r_belast) <= b).
  lra.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.

  revert ptd_r_belast ptd_r Hab1 Hptd.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := ptd) => /= [ x0 | [x0 y0] s IH] // Hab1 Hptd.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /SF_cut_down' /= ; case: Rle_dec => //= Hx0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply (Hab1 O (le_O_n _)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hab0.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_size_cons in Hab1.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (IH (fun i Hi => Hab1 (S i) (le_n_S _ _ Hi)) (ptd_cons _ _ Hptd)) => {IH}.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hptd (Hab1 O (le_O_n _)) (Hab1 1%nat (le_n_S _ _ (le_0_n _))) => {Hab1}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s} /= [ x1 | [x1 y1] s] //= Hptd Hx0 Hx1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /SF_cut_down' /SF_last /= -?(last_map (@fst R R)) -?unzip1_fst.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
  move => _ ; by apply Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => _ ; by apply Hab0.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /SF_cut_down' /SF_last /= -?(last_map (@fst R R)) -?unzip1_fst.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec _ lx1) => //= Hx2'.
  move => _ ; by apply Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => _ ; by apply Hab0.

  revert ptd_r_belast ptd_r Hab1 Hptd.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := ptd) => /= [ x0 | [x0 y0] s IH] // Hab1 Hptd.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /SF_cut_down' /= ; case: Rle_dec => //= Hx0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply (Hab1 O (le_O_n _)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hab0.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_size_cons in Hab1.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (IH (fun i Hi => Hab1 (S i) (le_n_S _ _ Hi)) (ptd_cons _ _ Hptd)) => {IH}.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hptd (Hab1 O (le_O_n _)) (Hab1 1%nat (le_n_S _ _ (le_0_n _))) => {Hab1}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s} /= [ x1 | [x1 y1] s] //= Hptd Hx0 Hx1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /SF_cut_down' /SF_last /= -?(last_map (@fst R R)) -?unzip1_fst.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
  move => _ ; by apply Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => _ ; by apply Hab0.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /SF_cut_down' /SF_last /= -?(last_map (@fst R R)) -?unzip1_fst.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec _ lx1) => //= Hx2'.
  move => _ ; by apply Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => _ ; by apply Hab0.

  apply Rle_trans with (2 := Rmin_r (Rmin alpha1 alpha2) alpha3).
  apply Rle_trans with (2 := Rlt_le _ _ Hstep).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rabs_right.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Ha -Hb in Hab0 ;
  revert ptd_r_belast ptd_r Hptd Hab0 ;
  apply SF_cons_ind with (s := ptd) => /= [x0 | [x0 y0] s IH] //=.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite /SF_cut_down' /SF_belast /SF_last /seq_step /= => Hptd Hab0.
  move: (proj1 Hab0) ; case: Rle_dec => //= _ _.
  rewrite (Rle_antisym _ _ (proj1 Hab0) (proj2 Hab0)) ; apply Req_le ; by ring.
  move => Hptd Hab0 ;
  move: (fun Hx1 => IH (ptd_cons _ _ Hptd) (conj Hx1 (proj2 Hab0))) => {IH}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_cut_down' /SF_belast /SF_last /=.
  move: (proj1 Hab0) ; case: (Rle_dec x0 _) => //= _ _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s)) => //= Hx1 IH.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (proj1 Hab0) Hx1 (IH Hx1) => {IH Hab0} Hx0.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s Hptd} /= [x1 | [x1 y1] s] /= Hx1.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite /seq_step /= => IH.
  apply Rle_trans with (1 := IH) ; by apply RmaxLess2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s)) => //= Hx2 IH.
  move: Hx2 IH ;
  apply SF_cons_dec with (s := s) => {s} /= [x2 | [x2 y2] s] /= Hx2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite /seq_step /= => IH.
  apply Rle_trans with (1 := IH) ; by apply RmaxLess2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s)) => //= Hx3 IH.
  apply Rle_trans with (1 := IH).
(* Goal: Rle b (@last R (@SF_h R ptd) (@unzip1 R R (@SF_t R ptd))) *)
  rewrite /seq_step /= ; by apply RmaxLess2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /seq_step /=.
  apply Rle_trans with (2 := RmaxLess2 _ _).
  apply Rle_trans with (2 := RmaxLess2 _ _).
  apply Rle_trans with (2 := RmaxLess1 _ _).
  apply Rle_trans with (2 := Rle_abs _), Rplus_le_compat_r, Rlt_le, Rnot_le_lt, Hx3.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /seq_step /=.
  apply Rle_trans with (2 := RmaxLess2 _ _).
  apply Rle_trans with (2 := RmaxLess1 _ _).
  apply Rle_trans with (2 := Rle_abs _), Rplus_le_compat_r, Rlt_le, Rnot_le_lt, Hx2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /seq_step /=.
  apply Rle_trans with (2 := RmaxLess1 _ _).
  apply Rle_trans with (2 := Rle_abs _), Rplus_le_compat_r, Rlt_le, Rnot_le_lt, Hx1.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rle_ge ; rewrite -Rminus_le_0.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  revert ptd_r_belast ptd_r ; rewrite -Ha in Hab0 ; move: (proj1 Hab0) ;
  apply SF_cons_ind with (s := ptd) => /= [x0 | [x0 y0] s IH] /= Hx0.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_cut_down' /SF_belast /SF_last /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by case: Rle_dec.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  move: IH ; rewrite /SF_cut_down' /SF_belast /SF_last /=.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 _) => //= _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s) _) => //= Hx1 IH.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hx1 (IH Hx1) => {IH}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s} /= [x1 | [x1 y1] s] //= Hx1.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s) _) => //=.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s} /= [x2 | [x2 y2] s] //= Hx2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s) _) => //=.

(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /alpha3 /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply (Rmax_case_strong (fmax - fmin)) => H.
  apply Req_le ; field.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply Rgt_not_eq, Rlt_le_trans with 1 ; by intuition.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite Rdiv_1 -{2}(Rmult_1_l (eps/2/2)).
  apply Rmult_le_compat_r, H.
  apply Rlt_le, eps4.

  clear H IH.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rplus_assoc Rmult_1_l.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply (f_equal (Rplus (ly0 * (lx1 - lx0)))).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -(Ropp_involutive (-_+_)).
  apply Ropp_eq_compat.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Ropp_plus_distr Ropp_involutive.
  revert ptd_r_last ptd_r_belast ptd_r ; move: (proj1 Hab0) ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Ha => {Hab0} ;
  apply SF_cons_ind with (s := ptd) => /= [x0 | [x0 y0] s IH] /= Hx0.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_cut_down' /=.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /Riemann_sum /= /plus /zero /scal /= /mult /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by ring.

(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s) lx1) => //= Hx1.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hx1 (IH Hx1) => {IH}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s} [x1 | [x1 y1] s] /= Hx1.
  rewrite /SF_cut_down' /= ;
  case: (Rle_dec x0 _) => //= _ ;
  case: (Rle_dec x1 _) => //= _.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite /Riemann_sum /= => _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /plus /zero /scal /= /mult /=.
  ring.
  rewrite /SF_cut_down' /= ;
  case: (Rle_dec x0 _) => //= _ ;
  case: (Rle_dec x1 _) => //= _ ;
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s) _) => //= Hx2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_belast /SF_last /SF_rcons /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (Riemann_sum_cons phi (x0,y0) ({| SF_h := x1; SF_t := (SF_h s, y1) :: seq_cut_down' (SF_t s) lx1 y1 |})).
  rewrite (Riemann_sum_cons phi (x0,y0) ({|
  SF_h := x1;
  SF_t := rcons (seq.belast (SF_h s, y1) (seq_cut_down' (SF_t s) lx1 y1))
               (lx1,
               (fst
                  (last (x1, y0)
                     (seq.belast (SF_h s, y1) (seq_cut_down' (SF_t s) lx1 y1))) +
                lx1) / 2) |})).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  move => <- /=.
  rewrite Rplus_assoc ;
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -!(last_map (@fst R R)) -!unzip1_fst /=.
  ring.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite /Riemann_sum /= => _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /plus /zero /scal /= /mult /=.
  ring.
  rewrite /SF_cut_down' /= ; case: Rle_dec => //= _ ; case: Rle_dec => //= _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /Riemann_sum /= /plus /zero /scal /= /mult /=.
  ring.

(* partie [lx1 ; b] *)

(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set ptd_l_head := (SF_head a (SF_cut_up' ptd lx1 a)).
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set ptd_l_behead := (SF_behead (SF_cut_up' ptd lx1 a)).
  set ptd_l := SF_cons (lx1, (lx1 + fst (SF_head a ptd_l_behead))/2) ptd_l_behead.

(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (IH ptd_l) => {IH} IH.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (_-_) with ((Int_SF ly (RList.cons lx1 lx) - 1 * Riemann_sum phi ptd_l) -
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (phi ((lx1 + fst (SF_head 0 ptd_l_behead))/2) - phi (snd ptd_l_head))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      * (lx1 - fst (SF_head 0 ptd_l_behead))).
  rewrite (double_var (eps/2)) ;
  apply Rle_trans with (1 := Rabs_triang _ _), Rplus_le_compat.
(* * hypothèse d'induction *)
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
  apply: IH.
(* ** ptd_l est une subdivision pointée *)
  case.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  move => _ ; move: (proj1 Hab0) ; rewrite -Ha => /= Hx0 ;
  case: Rle_dec => //= _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite seq_cut_up_head'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  move: Hx0 ; apply SF_cons_ind with (s := ptd) => /= [x0 | [x0 y0] s IH] /= Hx0.
  split ; apply Req_le ; field.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => //= Hx1.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hx1 (IH Hx1) => {IH}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s} /= [x1 | [x1 y1] s] //= Hx1.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => //= Hx2.
  lra.
  rewrite /ptd_l SF_lx_cons SF_ly_cons SF_size_cons => i Hi ;
  move: i {Hi} (lt_S_n _ _ Hi).
  revert ptd_l_behead ptd_l Hptd ;
  apply SF_cons_ind with (s := ptd)
    => /= [x0 | [x0 y0] s IH] /= Hptd.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_cut_up' /=.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => //=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  rewrite /SF_size /SF_behead /= => _ i Hi ; by apply lt_n_O in Hi.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (IH (ptd_cons _ _ Hptd)) => {IH}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_cut_up' /=.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 _) => //= Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s) _) => //= Hx1.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !seq_cut_up_head'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  move: Hx1 ; apply SF_cons_dec with (s := s) => {s Hptd} /= [x1 | [x1 y1] s] //= Hx1.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s) _) => //= Hx2.

(* * seq_step (SF_lx ptd_l) < alpha1 *)
  apply Rlt_le_trans with (2 := Rmin_l alpha1 alpha2).
  apply Rlt_le_trans with (2 := Rmin_l _ alpha3).
  apply Rle_lt_trans with (2 := Hstep).
  revert ptd_l_behead ptd_l ; move :(proj1 Hab0) ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Ha ; apply SF_cons_ind with (s := ptd) => /= [x0 | [x0 y0] /= s IH] Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /SF_cut_up' /= ; case: (Rle_dec x0 _) => //= _.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  rewrite /seq_step /= Rminus_eq_0 Rabs_R0 ; apply Rmax_case_strong ; by intuition.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /SF_cut_up' /= ; case: (Rle_dec x0 _) => //= _.
  move: IH ; rewrite /SF_cut_up' /= ; case: (Rle_dec (SF_h s) _) => //= Hx1 ;
  rewrite ?seq_cut_up_head' => IH.
  move: Hx1 (IH Hx1) => {IH} ;
  apply SF_cons_dec with (s := s) => {s} /= [x1 | [x1 y1] /= s] Hx1 IH.
  apply Rle_trans with (1 := IH) => {IH} ; rewrite /seq_step /= ;
  exact: RmaxLess2.
  move: IH ; case: (Rle_dec (SF_h s) _) => //= Hx2 IH.
  apply Rle_trans with (1 := IH) => {IH} ; rewrite /seq_step /= ;
  exact: RmaxLess2.
  apply Rle_trans with (1 := IH) => {IH} ; rewrite /seq_step /= ;
  exact: RmaxLess2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  clear IH ; rewrite /seq_step /=.
  apply Rle_max_compat_r.
  apply Rle_trans with (2 := Rle_abs _) ; rewrite Rabs_right.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rplus_le_compat_l, Ropp_le_contravar.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_ge, (Rminus_le_0 lx1 _), Rlt_le, Rnot_le_lt.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite /ptd_l /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite -Hb.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  move: (proj1 Hab0) ; rewrite -Ha /=;
  case: (Rle_dec (SF_h ptd) lx1) => //= _ _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite seq_cut_up_head'.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  move: Hab0 ; rewrite -Ha -Hb ;
  apply SF_cons_ind with (s := ptd) => /= [x0 | [x0 y0] s IH] /= [Hx0 Hlx1].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_antisym.
  move: (fun Hx1 => IH (conj Hx1 Hlx1)) => {IH} ;
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s) _) => //= Hx1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  move => IH ; rewrite -(IH Hx1) => {IH}.
  move: Hx1 Hlx1 ;
  apply SF_cons_dec with (s := s) => {s} /= [x1 | [x1 y1] /= s ] Hx1 Hlx1.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
  case: (Rle_dec (SF_h s) _) => /= Hx2 ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* ** transition 2 *)
  clear H IH.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rle_trans with ((fmax - fmin) * alpha3).
  rewrite Rabs_Ropp Rabs_mult ; apply Rmult_le_compat ; try apply Rabs_pos.
  apply Rabs_le_between.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Ropp_minus_distr'.
  suff H0 : a <= (lx1 + fst (SF_head 0 ptd_l_behead)) / 2 <= b.
  suff H1 : a <= snd ptd_l_head <= b.
  split ; apply Rplus_le_compat, Ropp_le_contravar ;
  by apply Hff.
  revert ptd_l_head Hab1 Hptd.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := ptd) => /= [ x0 | [x0 y0] s IH] // Hab1 Hptd.
  rewrite /SF_cut_up' /= ; case: Rle_dec => //= ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by intuition.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_size_cons in Hab1.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (IH (fun i Hi => Hab1 (S i) (le_n_S _ _ Hi)) (ptd_cons _ _ Hptd)) => {IH}.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hptd (Hab1 O (le_O_n _)) (Hab1 1%nat (le_n_S _ _ (le_0_n _))) => {Hab1}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s Hab0} /= [ x1 | [x1 y1] s] //= Hptd Hx0 Hx1.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_cut_up' /SF_head /=.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  move => _ ; split.
  apply Rle_trans with (1 := proj1 Hx0), (Hptd O (lt_O_Sn _)).
  apply Rle_trans with (2 := proj2 Hx1), (Hptd O (lt_O_Sn _)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => _ ; by intuition.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_cut_up' /SF_head /=.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec _ lx1) => //= Hx2'.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  move => _ ; split.
  apply Rle_trans with (1 := proj1 Hx0), (Hptd O (lt_O_Sn _)).
  apply Rle_trans with (2 := proj2 Hx1), (Hptd O (lt_O_Sn _)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => _ ; by intuition.

  cut (a <= fst (SF_head 0 ptd_l_behead) <= b).
  lra.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.

  revert ptd_l_behead ptd_l Hab1 Hptd.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := ptd) => /= [ x0 | [x0 y0] s IH] // Hab1 Hptd.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /SF_cut_down' /= ; case: Rle_dec => //= Hx0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hab0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply (Hab1 O (le_O_n _)).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_size_cons in Hab1.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (IH (fun i Hi => Hab1 (S i) (le_n_S _ _ Hi)) (ptd_cons _ _ Hptd)) => {IH}.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hptd (Hab1 O (le_O_n _)) (Hab1 1%nat (le_n_S _ _ (le_0_n _))) => {Hab1}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s} /= [ x1 | [x1 y1] s] //= Hptd Hx0 Hx1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /SF_cut_up' /SF_head /= -?(head_map (@fst R R)) -?unzip1_fst.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
  move => _ ; by apply Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec _ lx1) => //= Hx2'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite ?seq_cut_up_head'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
  move => _ ; by apply Hx0.
  move => _ ; by apply Hx0.

  revert ptd_l_behead ptd_l Hab1 Hptd.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_ind with (s := ptd) => /= [ x0 | [x0 y0] s IH] // Hab1 Hptd.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => //= Hx0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hab0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply (Hab1 O (le_O_n _)).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_size_cons in Hab1.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (IH (fun i Hi => Hab1 (S i) (le_n_S _ _ Hi)) (ptd_cons _ _ Hptd)) => {IH}.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hptd (Hab1 O (le_O_n _)) (Hab1 1%nat (le_n_S _ _ (le_0_n _))) => {Hab1}.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s} /= [ x1 | [x1 y1] s] //= Hptd Hx0 Hx1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -?(head_map (@fst R R)) -?unzip1_fst.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
  move => _ ; by apply Hx0.
  move => _ ; by apply Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x0 lx1) => //= Hx0'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec _ lx1) => //= Hx2'.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  by rewrite !seq_cut_up_head'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec x1 lx1) => //= Hx1'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec _ lx1) => //= Hx2'.
  move => _ ; by apply Hx0.
  move => _ ; by apply Hx0.
  move => _ ; by apply Hx0.

  apply Rle_trans with (2 := Rmin_r (Rmin alpha1 alpha2) alpha3).
  apply Rle_trans with (2 := Rlt_le _ _ Hstep).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Rabs_Ropp Rabs_right ?Ropp_minus_distr'.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Ha -Hb in Hab0 ;
  revert ptd_l_behead ptd_l Hptd Hab0 ;
  apply SF_cons_ind with (s := ptd) => /= [x0 | [x0 y0] s IH] //=.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite /seq_step /= => Hptd Hab0.
  move: (proj1 Hab0) ; case: Rle_dec => //= _ _.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply Req_le ; by ring.
  move => Hptd Hab0 ;
  move: (fun Hx1 => IH (ptd_cons _ _ Hptd) (conj Hx1 (proj2 Hab0))) => {IH}.
  move: (proj1 Hab0) ; case: (Rle_dec x0 _) => //= _ _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s)) => //= Hx1 IH.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (proj1 Hab0) Hx1 (IH Hx1) => {IH Hab0} Hx0.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply SF_cons_dec with (s := s) => {s Hptd} /= [x1 | [x1 y1] s] /= Hx1.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite /seq_step /= => IH.
  apply Rle_trans with (1 := IH) ; by apply RmaxLess2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s)) => //= Hx2 IH.
  move: Hx2 IH ;
  apply SF_cons_dec with (s := s) => {s} /= [x2 | [x2 y2] s] /= Hx2.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite /seq_step /= => IH.
  apply Rle_trans with (1 := IH) ; by apply RmaxLess2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s)) => //= Hx3 IH.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite !seq_cut_up_head' in IH |-*.
  apply Rle_trans with (1 := IH).
(* Goal: Rle b (@last R (@SF_h R ptd) (@unzip1 R R (@SF_t R ptd))) *)
  rewrite /seq_step /= ; by apply RmaxLess2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /seq_step /=.
  apply Rle_trans with (2 := RmaxLess2 _ _).
  apply Rle_trans with (2 := RmaxLess2 _ _).
  apply Rle_trans with (2 := RmaxLess1 _ _).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_trans with (2 := Rle_abs _), Rplus_le_compat_l, Ropp_le_contravar.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /seq_step /=.
  apply Rle_trans with (2 := RmaxLess2 _ _).
  apply Rle_trans with (2 := RmaxLess1 _ _).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_trans with (2 := Rle_abs _), Rplus_le_compat_l, Ropp_le_contravar.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /seq_step /=.
  apply Rle_trans with (2 := RmaxLess1 _ _).
  apply Rle_trans with (2 := Rle_abs _), Rplus_le_compat_l, Ropp_le_contravar, Hab0.

  apply Rle_ge, (Rminus_le_0 lx1).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  revert ptd_l_behead ptd_l ; rewrite -Ha -Hb in Hab0 ; move: Hab0 ;
  apply SF_cons_ind with (s := ptd) => /= [x0 | [x0 y0] s IH] /= Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => /= _.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Rle_refl.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: (proj2 Hx0).
  move: (proj1 Hx0) ; case: Rle_dec => //= _ _.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (fun Hx1 => IH (conj Hx1 (proj2 Hx0))) => {IH}.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s)) => //= Hx1 IH.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite !seq_cut_up_head' in IH |-* ; move: (IH Hx1) => {IH}.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  move: Hx0 Hx1 ; apply SF_cons_dec with (s := s) => {s} /= [x1 | [x1 y1] /= s] Hx0 Hx1 IH.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Rle_refl.
  move: IH ; case: (Rle_dec (SF_h s)) => /= Hx2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rnot_le_lt, Hx1.

(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /alpha3 /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply (Rmax_case_strong (fmax - fmin)) => H.
  apply Req_le ; field.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply Rgt_not_eq, Rlt_le_trans with 1 ; by intuition.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite Rdiv_1 -{2}(Rmult_1_l (eps/2/2)).
  apply Rmult_le_compat_r, H.
  apply Rlt_le, eps4.

  clear H IH.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite !Rmult_1_l {1 2}/Rminus Rplus_assoc -Ropp_plus_distr.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply (f_equal (Rminus _)) => /=.
  rewrite /ptd_l /ptd_l_behead /ptd_l_head /= /SF_cut_up' /= ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  move: Hab0 ; rewrite -Ha -Hb /= ;
  case => [Hx0 Hlx1].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h ptd)) => //= _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite ?seq_cut_up_head' /SF_ly /= Riemann_sum_cons /=.
  move: Hx0 Hlx1 ; apply SF_cons_ind with (s := ptd)
    => [x0 | [x0 y0] s /= IH] /= Hx0 Hlx1.
  rewrite /Riemann_sum /= /plus /zero /scal /= /mult /= ; ring.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s)) => //= Hx1.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (IH Hx1 Hlx1) => /= {IH}.
  move: Hx1 Hlx1 ; apply SF_cons_dec with (s := s)
    => {s} [x1 | [x1 y1] s /=] /= Hx1 Hlx1 IH.
  rewrite /Riemann_sum /= /plus /zero /scal /= /mult /= ; ring.
  move: IH ; case: (Rle_dec (SF_h s)) => //= Hx2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  move => <- ; apply Rminus_diag_uniq ; ring_simplify.
  move: Hx2 Hlx1 y1 ; apply SF_cons_ind with (s := s)
    => {s} [x2 | [x2 y2] s /= IH] /= Hx2 Hlx1 y1.
  ring.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Rle_dec (SF_h s)) => //= Hx3.
  by apply IH.
  ring.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /Riemann_sum /= /plus /zero /scal /= /mult /=.
  ring_simplify.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  repeat apply f_equal.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by elim: (SF_t s) (0) (y0).

  replace (fst (last (SF_h ptd, SF_h ptd) (SF_t ptd)))
    with (last (SF_h ptd) (unzip1 (SF_t ptd))).
Focus 2.
pattern (SF_h ptd) at 1.
replace (SF_h ptd) with (fst (SF_h ptd, SF_h ptd)) by auto.
elim: (SF_t ptd) (SF_h ptd, SF_h ptd) => //=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  by rewrite Hb Ha.

  replace lx1 with (pos_Rl (RList.cons lx0 (RList.cons lx1 lx)) 1) by reflexivity.
  move: (proj1 (proj2 Had)) (proj1 (proj2 (proj2 Had))) ; rewrite /Rmin /Rmax ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  case: Rle_dec => // _ <- <-.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -(seq2Rlist_bij (RList.cons lx0 _)) !nth_compat size_compat.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite nth0.
  apply (sorted_head (Rlist2seq (RList.cons lx0 (RList.cons lx1 lx))) 1).
  apply sorted_compat ; rewrite seq2Rlist_bij ; apply Had.
  simpl ; by apply lt_n_S, lt_O_Sn.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  simpl ; rewrite -last_nth.
  apply (sorted_last (Rlist2seq (RList.cons lx0 (RList.cons lx1 lx))) 1) with (x0 := 0).
  apply sorted_compat ; rewrite seq2Rlist_bij ; apply Had.
  simpl ; by apply lt_n_S, lt_O_Sn.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Ha -Hb /SF_lx /= => i Hi.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply le_lt_n_Sm in Hi ; rewrite -SF_size_lx /SF_lx in Hi.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: (sorted_head (SF_h ptd :: unzip1 (SF_t ptd)) i (ptd_sort _ Hptd) Hi).
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: (sorted_last (SF_h ptd :: unzip1 (SF_t ptd)) i (ptd_sort _ Hptd) Hi).

  clear H IH.
  move => x Hx ; case: (sorted_dec ([:: lx0, lx1 & Rlist2seq lx]) 0 x).
  apply sorted_compat ; rewrite /= seq2Rlist_bij ; apply Had.
  move: (proj1 (proj2 Had)) (proj1 (proj2 (proj2 Had))) ; rewrite /Rmin /Rmax ;
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => // _.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -nth0 -nth_last /= => -> Hb'.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hx.
  elim: (lx) (lx1) Hb' => /= [ | h1 s IH] h0 Hb'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  rewrite Hb' ; by apply Hx.
  by apply IH.
  case => i ; case ; case ; case => {Hx} Hx Hx' Hi.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (proj2 (proj2 (proj2 (proj2 Had))) i).
  suff H : fmin1 <= pos_Rl (RList.cons ly0 ly) i <= fmax1.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply Rle_trans with (1 := Rmin_l _ _), H.
  apply Rle_trans with (2 := RmaxLess1 _ _), H.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -(seq2Rlist_bij (RList.cons ly0 _)) nth_compat /= /fmin1 /fmax1 .
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have : (S i < size (ly0 :: Rlist2seq ly))%nat.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (proj1 (proj2 (proj2 (proj2 Had)))) Hi.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite /= -{1}(seq2Rlist_bij lx) -{1}(seq2Rlist_bij ly) ?size_compat /=
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
      => -> ; exact: lt_S_n.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: i {Hx Hx' Hi}.
  elim: (ly0 :: Rlist2seq ly) => [ | h0 s IH] i Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: i Hi => /= [ | i] Hi.
  split ; [exact: Rmin_l | exact: RmaxLess1].
  split ;
  [apply Rle_trans with (1 := Rmin_r _ _)
  | apply Rle_trans with (2 := RmaxLess2 _ _)] ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply IH ; by apply lt_S_n.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  simpl in Hi |-* ; rewrite -size_compat seq2Rlist_bij in Hi ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by intuition.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -nth_compat /= seq2Rlist_bij in Hx ; exact: Hx.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -nth_compat /= seq2Rlist_bij in Hx' ; exact: Hx'.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Hx.
  suff H : fmin2 <= phi (nth 0 [:: lx0, lx1 & Rlist2seq lx] i) <= fmax2.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply Rle_trans with (1 := Rmin_r _ _), H.
  apply Rle_trans with (2 := RmaxLess2 _ _), H.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /fmin2 /fmax2 .
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: i Hi {Hx Hx'}.
  elim: ([:: lx0, lx1 & Rlist2seq lx]) => [ | h0 s IH] i Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: i Hi => /= [ | i] Hi.
  split ; [exact: Rmin_l | exact: RmaxLess1].
  split ;
  [apply Rle_trans with (1 := Rmin_r _ _)
  | apply Rle_trans with (2 := RmaxLess2 _ _)] ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply IH ; by apply lt_S_n.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  have : (((size [:: lx0, lx1 & Rlist2seq lx] - 1)%nat) <
    size [:: lx0, lx1 & Rlist2seq lx])%nat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (size [:: lx0, lx1 & Rlist2seq lx] - 1)%nat with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (S (size [:: lx0, lx1 & Rlist2seq lx] - 2)) by (simpl ; intuition).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  move: (size [:: lx0, lx1 & Rlist2seq lx] - 2)%nat => i Hi.
  case ; case => {Hx} Hx ; [ case => Hx' | move => _ ].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (proj2 (proj2 (proj2 (proj2 Had))) i).
  suff H : fmin1 <= pos_Rl (RList.cons ly0 ly) i <= fmax1.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply Rle_trans with (1 := Rmin_l _ _), H.
  apply Rle_trans with (2 := RmaxLess1 _ _), H.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -(seq2Rlist_bij (RList.cons ly0 _)) nth_compat /= /fmin1 /fmax1 .
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have : (i < size (ly0 :: Rlist2seq ly))%nat.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (proj1 (proj2 (proj2 (proj2 Had)))) Hi.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite /= -{1}(seq2Rlist_bij lx) -{1}(seq2Rlist_bij ly) ?size_compat /=
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
      => -> ; exact: lt_S_n.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: i {Hx Hx' Hi}.
  elim: (ly0 :: Rlist2seq ly) => [ | h0 s IH] i Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: i Hi => /= [ | i] Hi.
  split ; [exact: Rmin_l | exact: RmaxLess1].
  split ;
  [apply Rle_trans with (1 := Rmin_r _ _)
  | apply Rle_trans with (2 := RmaxLess2 _ _)] ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply IH ; by apply lt_S_n.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  simpl in Hi |-* ; rewrite -size_compat seq2Rlist_bij in Hi ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by intuition.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -nth_compat /= seq2Rlist_bij in Hx ; exact: Hx.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -nth_compat /= seq2Rlist_bij in Hx' ; exact: Hx'.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Hx'.
  suff H : fmin2 <= phi (nth 0 [:: lx0, lx1 & Rlist2seq lx] (S i)) <= fmax2.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply Rle_trans with (1 := Rmin_r _ _), H.
  apply Rle_trans with (2 := RmaxLess2 _ _), H.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /fmin2 /fmax2 .
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: i Hi {Hx Hx'}.
  elim: ([:: lx0, lx1 & Rlist2seq lx]) => [ | h0 s IH] i Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: s IH Hi => /= [ | h1 s] IH Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_S_n, lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: i Hi => /= [ | i] Hi.
  split ;
  [ apply Rle_trans with (1 := Rmin_r _ _) ; exact: Rmin_l
  | apply Rle_trans with (2 := RmaxLess2 _ _) ; exact: RmaxLess1].
  split ;
  [apply Rle_trans with (1 := Rmin_r _ _)
  | apply Rle_trans with (2 := RmaxLess2 _ _)] ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply IH ; by apply lt_S_n.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Hx.
  suff H : fmin2 <= phi (nth 0 [:: lx0, lx1 & Rlist2seq lx] i) <= fmax2.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply Rle_trans with (1 := Rmin_r _ _), H.
  apply Rle_trans with (2 := RmaxLess2 _ _), H.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /fmin2 /fmax2 .
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: i Hi {Hx}.
  elim: ([:: lx0, lx1 & Rlist2seq lx]) => [ | h0 s IH] i Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: i Hi => /= [ | i] Hi.
  split ; [exact: Rmin_l | exact: RmaxLess1].
  split ;
  [apply Rle_trans with (1 := Rmin_r _ _)
  | apply Rle_trans with (2 := RmaxLess2 _ _)] ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply IH ; by apply lt_S_n.

(* preuve de H *)
  clear eps eps2 IH eps4 alpha1.
  move: (proj1 (proj2 Had)) => /= ; rewrite /Rmin ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    case: Rle_dec => //= _ <-.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (proj1 Had O (lt_O_Sn _)) => /= Hl0l1.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (proj2 (proj2 (proj2 (proj2 Had))) O (lt_O_Sn _)) => /= Hval.
  clear a b Hab Had lx ly.
  rename lx0 into a ; rename lx1 into b ;
  rename ly0 into c ; rename Hl0l1 into Hab.

(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set fmin := Rmin (Rmin (phi a) (phi b)) c.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set fmax := Rmax (Rmax (phi a) (phi b)) c.

(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  move => eps ; set eps2 := pos_div_2 eps.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  have Halpha : 0 < eps2 / (Rmax (fmax - fmin) 1).
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    apply Rdiv_lt_0_compat.
    apply eps2.
    apply Rlt_le_trans with (2 := RmaxLess2 _ _), Rlt_0_1.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set alpha := mkposreal _ Halpha.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  exists alpha => ptd.
  apply SF_cons_ind with (s := ptd)
    => {ptd} [x0 | [x0 y0] ptd IH] Hptd Hstep Ha Hb ; simpl in Ha, Hb.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Ha -Hb /Riemann_sum  /= ;
  rewrite Rminus_eq_0 Rmult_0_r Rminus_0_r Rabs_R0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, eps.
  move: (fun Ha => IH (ptd_cons _ _ Hptd) (Rle_lt_trans _ _ _ (RmaxLess2 _ _) Hstep) Ha Hb)
    => {IH} IH.
  move: (proj1 (ptd_sort _ Hptd)) ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite Ha in Hptd, Hstep |- * => {x0 Ha} ;
  case => /= Ha.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  rewrite Riemann_sum_cons /= /plus /zero /scal /= /mult /= => {IH}.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (_-_) with ((c-phi y0) * (SF_h ptd - a)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    + (c * (b - SF_h ptd) - Riemann_sum phi ptd))
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by ring.
  rewrite (double_var eps) ;
  apply Rle_trans with (1 := Rabs_triang _ _), Rplus_le_compat.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rle_trans with ((fmax - fmin) * alpha).
  rewrite Rabs_mult ; apply Rmult_le_compat ; try exact: Rabs_pos.
  suff : a <= y0 <= b.
  case ; case => Ha'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => Hb'.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Hval.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite Rminus_eq_0 Rabs_R0 -Rminus_le_0 /fmin /fmax.
  rewrite /Rmin /Rmax ; case: Rle_dec ; case: Rle_dec ;
  case: Rle_dec => // H0 H1 H2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rnot_le_lt, H1.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  by apply Rle_refl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rnot_le_lt, H0.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  by apply Rle_refl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rnot_le_lt, H0.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  by split.
  rewrite Hb' ;
  apply Rabs_le_between ; rewrite Ropp_minus_distr' ; split ;
  apply Rplus_le_compat, Ropp_le_contravar.
  by apply Rmin_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_trans with (2 := RmaxLess1 _ _), RmaxLess2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply RmaxLess2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_trans with (1 := Rmin_l _ _), Rmin_r.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Ha' => _ ;
  apply Rabs_le_between ; rewrite Ropp_minus_distr' ; split ;
  apply Rplus_le_compat, Ropp_le_contravar.
  by apply Rmin_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_trans with (2 := RmaxLess1 _ _), RmaxLess1.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply RmaxLess2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_trans with (1 := Rmin_l _ _), Rmin_l.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply (Hptd O (lt_O_Sn _)).
  apply Rle_trans with (SF_h ptd).
  apply (Hptd O (lt_O_Sn _)).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Hb ;
  apply (sorted_last (SF_lx ptd) 0 (proj2 (ptd_sort _ Hptd)) (lt_O_Sn _))
    with (x0 := 0).
  apply Rlt_le, Rle_lt_trans with (2 := Hstep) ;
  rewrite /seq_step /= ; apply RmaxLess1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /alpha /= ; apply (Rmax_case_strong (fmax-fmin)) => H.
  apply Req_le ; field.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rgt_not_eq, Rlt_le_trans with (1 := Rlt_0_1), H.
  rewrite Rdiv_1 -{2}(Rmult_1_l (eps/2)) ; apply Rmult_le_compat_r.
  apply Rlt_le, eps2.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
  apply H.

  move: (ptd_cons _ _ Hptd)
  (Rle_lt_trans _ _ _ (RmaxLess2 _ _) Hstep : seq_step (SF_lx ptd) < alpha)
  Ha Hb => {Hptd Hstep y0} Hptd Hstep Ha Hb.
  suff : SF_h ptd <= b.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => Hx0.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hptd Hstep Ha Hb Hx0.
  apply SF_cons_ind with (s := ptd) => {ptd}
    [x0 | [x0 y0] ptd IH] Hptd Hstep /= Ha Hb Hx0.
  contradict Hb ; apply Rlt_not_eq, Hx0.
  move: (fun Hx1 => IH (ptd_cons _ _ Hptd) (Rle_lt_trans _ _ _ (RmaxLess2 _ _) Hstep)
    (Rlt_le_trans _ _ _ Ha (proj1 (ptd_sort _ Hptd))) Hb Hx1) => {IH} IH.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Riemann_sum_cons /=.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have : SF_h ptd <= b.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite -Hb ; apply (sorted_last ((SF_h ptd)::(unzip1 (SF_t ptd))) O) with (x0 := 0).
    apply ptd_sort, (ptd_cons (x0,y0)), Hptd.
    apply lt_O_Sn.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => Hx1.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Hval /plus /scal /= /mult /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (_-_) with (c * (b - SF_h ptd) - Riemann_sum phi ptd) by ring.
  by apply IH.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply Rlt_le_trans with (1 := Ha), (Hptd O (lt_O_Sn _)).
  apply Rle_lt_trans with (2 := Hx1), (Hptd O (lt_O_Sn _)).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Hx1 Riemann_sum_zero.
  change zero with 0.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /plus /scal /= /mult /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (_ - _) with ((c - phi y0) * (b - x0)) by ring.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rle_trans with ((fmax - fmin) * alpha).
  rewrite Rabs_mult ; apply Rmult_le_compat ; try exact: Rabs_pos.
  suff : a <= y0 <= b.
  case ; case => Ha'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => Hb'.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Hval.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite Rminus_eq_0 Rabs_R0 -Rminus_le_0 /fmin /fmax.
  rewrite /Rmin /Rmax ; case: Rle_dec ; case: Rle_dec ;
  case: Rle_dec => // H0 H1 H2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rnot_le_lt, H1.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  by apply Rle_refl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rnot_le_lt, H0.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  by apply Rle_refl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rnot_le_lt, H0.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  by split.
  rewrite Hb' ;
  apply Rabs_le_between ; rewrite Ropp_minus_distr' ; split ;
  apply Rplus_le_compat, Ropp_le_contravar.
  by apply Rmin_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_trans with (2 := RmaxLess1 _ _), RmaxLess2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply RmaxLess2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_trans with (1 := Rmin_l _ _), Rmin_r.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -Ha' => _ ;
  apply Rabs_le_between ; rewrite Ropp_minus_distr' ; split ;
  apply Rplus_le_compat, Ropp_le_contravar.
  by apply Rmin_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_trans with (2 := RmaxLess1 _ _), RmaxLess1.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply RmaxLess2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_trans with (1 := Rmin_l _ _), Rmin_l.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply Rlt_le, Rlt_le_trans with (1 := Ha), (Hptd O (lt_O_Sn _)).
  apply Rle_trans with (SF_h ptd).
  apply (Hptd O (lt_O_Sn _)).
  by apply Req_le.
  apply Rlt_le, Rle_lt_trans with (2 := Hstep) ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /seq_step /= -Hx1 ; apply RmaxLess1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite /alpha /= ; apply (Rmax_case_strong (fmax-fmin)) => H.
  apply Req_le ; field.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rgt_not_eq, Rlt_le_trans with (1 := Rlt_0_1), H.
  rewrite Rdiv_1 -{2}(Rmult_1_l (eps/2)) ; apply Rmult_le_compat_r.
  apply Rlt_le, eps2.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
  apply H.
  apply ptd_sort, (ptd_cons (x0,y0)), Hptd.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite /SF_lx /= Hb.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Hx0 Riemann_sum_zero.
  change zero with 0.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (c * (b - b) - 0) with 0 by ring.
  rewrite Rabs_R0 ; apply Rlt_le, eps2.
  apply ptd_sort, Hptd.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite /SF_lx /= Hb.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite -Hb ; apply (sorted_last ((SF_h ptd)::(unzip1 (SF_t ptd))) O) with (x0 := 0).
    apply ptd_sort, Hptd.
    apply lt_O_Sn.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite Riemann_sum_cons /= -Ha.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rminus_eq_0 scal_zero_l plus_zero_l.
  by apply IH.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma ex_RInt_Reals_1 (f : R -> R) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  Riemann_integrable f a b -> ex_RInt f a b.
Proof.
(* Goal: forall _ : Riemann_integrable f a b, @ex_RInt R_NormedModule f a b *)
  move => pr ; exists (RiemannInt pr).
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: ex_RInt_Reals_aux_1.
Qed.


(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma ex_RInt_Reals_0 (f : R -> R) (a b : R) :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  ex_RInt f a b -> Riemann_integrable f a b.
Proof.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  wlog: a b /(a < b) => [Hw | Hab ] Hex.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Rle_lt_dec a b) => Hab.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Rle_lt_or_eq_dec _ _ Hab) => {Hab} Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite -Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply RiemannInt_P7.
    apply ex_RInt_swap in Hex ;
    apply RiemannInt_P1 ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hw.
  assert ({If : R | is_RInt f a b If}).
    exists (RInt f a b).
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: RInt_correct.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: H => If HIf.
  generalize (proj1 (filterlim_locally _ If) HIf).
  clear HIf.
  intros HIf.
  set (E := fun eps : posreal =>
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (fun alpha => 0 < alpha <= b-a + 1 /\
      forall ptd : SF_seq,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
        pointed_subdiv ptd ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
        seq_step (SF_lx ptd) < alpha ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
        SF_h ptd = Rmin a b ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
        last (SF_h ptd) (SF_lx ptd) = Rmax a b ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
        Rabs (If - sign (b - a) * Riemann_sum f ptd) < eps)).
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have E_bnd : forall eps : posreal, bound (E eps).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    move => eps ; exists (b-a+1) => x [Hx _] ; by apply Hx.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have E_ex : forall eps : posreal, exists x, (E eps x).
    move => eps ; case: (HIf eps) => {HIf} alpha HIf.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    exists (Rmin alpha (b-a + 1)) ; split.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    apply Rmin_case_strong => H.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply alpha.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: H.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
    apply Rplus_le_lt_0_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply (Rminus_le_0 a b), Rlt_le.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: Rlt_0_1.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: Rle_refl.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
    intros.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rabs_minus_sym.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
    apply: HIf.
    move: H0 ; apply Rmin_case_strong.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    move => Halp Hstep ; by apply Rlt_le_trans with (b-a+1).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: H.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: H1.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: H2.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set alpha := fun eps : posreal => proj1_sig (completeness (E eps) (E_bnd eps) (E_ex eps)).
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have Ealpha : forall eps : posreal, (E eps (alpha eps)).
    revert alpha ; move => /= eps.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (E_ex eps) => alp H.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    case: completeness => alpha [ub lub] /= ; split.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
    apply Rlt_le_trans with alp.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
    by apply H.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply ub.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply: lub => x [Hx _] ; by apply Hx.
(* Goal: forall (x : R) (_ : and (Rle a x) (Rle x b)), @continuous R_UniformSpace R_UniformSpace (fun x0 : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x0) (f x0)) x *)
    intros.
    apply Rnot_le_lt ; contradict H1.
(* Goal: not (Rlt x (@fst R R x0)) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    apply Rle_not_lt.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
    apply: lub => x [Hx1 Hx2].
    apply Rnot_lt_le ; contradict H1.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rlt_not_le, Hx2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  have Hn : forall eps : posreal, {n : nat | (b-a)/(INR n + 1) < alpha eps}.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move => eps.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    have Hn : 0 <= (b-a)/(alpha eps).
      apply Rdiv_le_0_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply Rlt_le, Rgt_minus.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply Ealpha.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
    set n := (nfloor _ Hn).
    exists n.
    apply Rlt_div_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply INRp1_pos.
    rewrite Rmult_comm ; apply Rlt_div_l.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Ealpha.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    rewrite /n /nfloor ; case: nfloor_ex => /= n' Hn'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hn'.

(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /Riemann_integrable.
  suff H : forall eps : posreal,
    {phi : StepFun a b &
    {psi : StepFun a b |
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (forall t : R, Rmin a b <= t <= Rmax a b -> Rabs (f t - phi t) <= psi t) /\
    Rabs (RiemannInt_SF psi) <= eps}}.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  move => eps ; set eps2 := pos_div_2 eps.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (H eps2) => {H} phi [psi [H H0]].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  exists phi ; exists psi ; split.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: H.
  apply Rle_lt_trans with (1 := H0).
  apply Rminus_gt ; simpl ; field_simplify ; rewrite Rdiv_1 ; by apply eps2.

(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  move => eps ; set eps2 := pos_div_2 eps.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Hn eps2) => {Hn} n Hn.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (Ealpha eps2) => {HIf} Halpha HIf.

(* Construire phi *)
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set phi := sf_SF_val_fun f a b n.
  exists phi.
(* Construire psi *)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  set psi1 := SF_sup_r (fun t => Rabs (f t - phi t)) a b n.
  have Haux : forall x,
    {i : nat | x = nth 0 (unif_part a b n) i /\ (i < size (unif_part a b n))%nat}
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    + {(forall i, (i < size (unif_part a b n))%nat -> x <> nth 0 (unif_part a b n) i)}.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move => x.
    have : {n0 : nat | x = nth 0 (unif_part a b n) n0
      /\ (n0 < size (unif_part a b n))%nat} +
      {(forall n0 : nat,
      ~ (x = nth 0 (unif_part a b n) n0
      /\ (n0 < size (unif_part a b n))%nat))}.
    apply (LPO (fun i => x = nth 0 (unif_part a b n) i
      /\ (i < size (unif_part a b n))%nat)).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move => i.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Req_EM_T x (nth 0 (unif_part a b n) i)) => Hx.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (lt_dec i (size (unif_part a b n))) => Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    left ; split ; by [].
    right ; contradict Hi ; by apply Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    right ; contradict Hx ; by apply Hx.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case => [[i Hi] | Hx].
    left ; by exists i.
    right => i Hi ;
    move: (Hx i) => {Hx} Hx ;
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    contradict Hx ; by split.
  set psi2_aux := fun x => match Haux x with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    | inleft Hi => Rabs (f x - phi x) - psi1 x
    | inright _ => 0
  end.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set psi2_ly := seq2Rlist (SF_ly (SF_seq_f1 (fun _ => 0) (unif_part a b n))).
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have psi2_ad : adapted_couple psi2_aux a b (seq2Rlist (unif_part a b n)) psi2_ly.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply sorted_compat, unif_part_sort, Rlt_le.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
    rewrite /Rmin ; case: Rle_dec (Rlt_le _ _ Hab) => //= _ _ ;
    field ; apply Rgt_not_eq ; by intuition.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite size_compat size_mkseq nth_compat nth_mkseq ?S_INR /=.
    rewrite /Rmax ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _ ;
    field ; apply Rgt_not_eq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by rewrite !size_compat SF_ly_f1 size_belast' size_map.
    rewrite size_compat => i Hi ;
    rewrite !nth_compat SF_ly_f1 => x Hx.
    rewrite /psi2_aux => {psi2_aux} ;
    case: Haux => [ [j [Hx' Hj]] | Hx' ].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite Hx' in Hx |- * ; case: Hx => Hxi Hxj.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (lt_dec i j) => Hij.
(* Goal: not (Rlt x (@fst R R x0)) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    contradict Hxj ; apply Rle_not_lt.
    apply sorted_incr.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply unif_part_sort, Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: not (Rlt x (@fst R R x0)) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    contradict Hxi ; apply Rle_not_lt.
    apply sorted_incr.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply unif_part_sort, Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply not_lt.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
    move: i Hi {Hx} ;
    elim: (unif_part a b n) => /= [ i Hi | x0].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case => /= [ | x1 s] IH i Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: i Hi => /= [ | i] Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply IH, lt_S_n.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have psi2_is : IsStepFun psi2_aux a b.
    exists (seq2Rlist (unif_part a b n)).
    exists psi2_ly.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set psi2 := mkStepFun psi2_is.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set psi := mkStepFun (StepFun_P28 1 psi1 psi2).

  exists psi.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
have Hfin : forall i, (S i < size (unif_part a b n))%nat ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  is_finite (Sup_fct (fun t0 : R => Rabs (f t0 - phi t0))
    (nth 0 (unif_part a b n) i) (nth 0 (unif_part a b n) (S i))).
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (ex_RInt_ub f a b Hex) => M HM.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (StepFun_bound phi) => M' HM'.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  have : exists m, forall x : R, Rmin a b <= x <= Rmax a b -> m <= phi x.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    case: (StepFun_bound (mkStepFun (StepFun_P28 (-1) (mkStepFun (StepFun_P4 a b 0)) phi)))
    => /= m' Hm'.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    exists (-m') => x Hx.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    replace (phi x) with (- (fct_cte 0 x + -1 * phi x))
      by (rewrite /fct_cte /= ; ring).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Ropp_le_contravar, Hm'.
  case => m' Hm' i ;
  rewrite size_mkseq => Hi ;
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !nth_mkseq.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /Sup_fct.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  have H : (a + INR i * (b - a) / (INR n + 1)) <
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (a + (INR (S i)) * (b - a) / (INR n + 1)).
    rewrite S_INR ; apply Rminus_gt ; field_simplify.
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    rewrite Rdiv_1 Rplus_comm ; apply Rdiv_lt_0_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rgt_minus.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply INRp1_pos.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rgt_not_eq, INRp1_pos.
  move: (Rlt_not_eq _ _ H) ; case: Req_EM_T => // H0 _.
  rewrite /Rmin /Rmax ;
  case: Rle_dec (Rlt_le _ _ H) => // _ _.
  rewrite /Lub_Rbar ; case: ex_lub_Rbar ; case => [l | | ] [ub lub] /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  case: (lub (Finite (Rmax (M - m') (-(-M - M'))))) => //.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  move => _ [x [-> Hx]].
  apply Rabs_le_between_Rmax.
  suff H2 : Rmin a b <= x <= Rmax a b.
  split ; apply Rplus_le_compat, Ropp_le_contravar.
  apply Ropp_le_cancel, Rle_trans with (Rabs (f x)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rabs_maj2.
(* Goal: Rle b (@last R (@SF_h R ptd) (@unzip1 R R (@SF_t R ptd))) *)
  rewrite Ropp_involutive ; by apply HM.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply HM'.
  apply Rle_trans with  (Rabs (f x)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_abs.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply HM.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Hm'.
  rewrite /Rmin /Rmax ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _ ; split ;
  apply Rlt_le.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace a with (a + INR O * (b - a) / (INR n + 1))
    by (simpl ; field ; apply Rgt_not_eq, INRp1_pos).
  apply Rle_lt_trans with (2 := proj1 Hx).
  apply Rplus_le_compat_l, Rmult_le_compat_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply Rlt_le, Rinv_0_lt_compat ; by intuition.
  apply Rmult_le_compat_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rgt_minus.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply le_INR ; by intuition.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace b with (a + INR (S n) * (b - a) / (INR n + 1))
    by (rewrite S_INR ; field ; apply Rgt_not_eq, INRp1_pos).
  apply Rlt_le_trans with (1 := proj2 Hx).
  apply Rplus_le_compat_l, Rmult_le_compat_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply Rlt_le, Rinv_0_lt_compat ; by intuition.
  apply Rmult_le_compat_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rgt_minus.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply le_INR ; by intuition.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  move: (a + INR i * (b - a) / (INR n + 1)) (a + INR (S i) * (b - a) / (INR n + 1)) ub H.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  clear => a0 b0 ub H.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  specialize (ub (Rabs (f ((a0 + b0) / 2) - phi ((a0 + b0) / 2)))) ; simpl in ub.
  assert (exists x : R,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    Rabs (f ((a0 + b0) / 2) - phi ((a0 + b0) / 2)) = Rabs (f x - phi x) /\
    a0 < x < b0).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  eexists ; split => //.
  lra.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].

(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply SSR_leq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply SSR_leq ; by intuition.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
have Hfin' : forall t, is_finite (SF_sup_fun (fun t : R => Rabs (f t - phi t)) a b n t).
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /SF_sup_fun ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_fun /SF_sup_seq.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (unif_part a b n) Hfin => [ | x0 sx] /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => _ t ; by case: Rle_dec.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: sx => [ | x1 sx] /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => _ t ; by case: Rle_dec.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => H t.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rlt_dec => Hx0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
  elim: sx x0 x1 H Hx0 => [ | x2 sx IH] x0 x1 /= H Hx0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => Hx1.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply (H O) ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rlt_dec => Hx1.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply (H O) ; by intuition.
  apply IH.
  move => i Hi ; apply (H (S i) (lt_n_S _ _ Hi)).
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Hx1.

(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Partie 1 *)
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => t Ht_ab.
  move: Ht_ab ; rewrite /Rmin /Rmax ;
  case: Rle_dec (Rlt_le _ _ Hab) => // _ _ Ht_ab.
  rewrite /= /psi2_aux /= ; case: (Haux t) => [ [i Hi] | Hi ] ;
  ring_simplify.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Rle_refl.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  change (Rbar_le (Rabs (f t - phi t)) (real (SF_sup_fun (fun t0 : R => Rabs (f t0 - phi t0)) a b n t))).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Hfin'.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /SF_sup_fun ; case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /SF_fun /SF_sup_seq.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (unif_part_sort a b n (Rlt_le _ _ Hab)).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Ht_ab.
  pattern b at 1 ; replace b with (last 0 (unif_part a b n)).
  pattern a at 1 ; replace a with (head 0 (unif_part a b n)).
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have : (0 < size (unif_part a b n))%nat.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    rewrite size_mkseq ; exact: lt_O_Sn.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: (unif_part a b n) Hi => [ | x0 sx] Hi Hsx Ht_ab Hsort /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_irrefl in Hsx.
  clear Hsx.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: sx Hsort Hi Ht_ab => [ | x1 sx] Hsort /= Hi [Ht_a Ht_b].
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (Rle_antisym _ _ Ht_b Ht_a) => Ht.
  contradict Ht ; apply (Hi O (lt_n_Sn _)).
  apply Rle_not_lt in Ht_a.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rlt_dec => // _.
  elim: sx x0 x1 Hsort Ht_a Ht_b Hi => [ | x2 sx IH] x0 x1 Hsort /= Ht_a Ht_b Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rle_dec => // _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /Sup_fct /Lub_Rbar.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have H : x0 < x1.
    apply Rlt_trans with t.
    apply Rnot_lt_le in Ht_a ; case: Ht_a => Ht_a.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
    contradict Ht_a ; apply sym_not_eq, (Hi O).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_O_Sn.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Ht_b => Ht_b.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
    contradict Ht_b ; apply (Hi 1%nat).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_n_Sn.
  move: (Rlt_not_eq _ _ H) ;
  case: Req_EM_T => // H0 _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: ex_lub_Rbar => l lub /=.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  apply lub ; exists t ; split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
  rewrite /Rmin /Rmax ; case: Rle_dec (proj1 Hsort) => // _ _ ;
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply Rnot_lt_le in Ht_a ; case: Ht_a => Ht_a.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
  contradict Ht_a ; apply sym_not_eq, (Hi O).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_O_Sn.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Ht_b => Ht_b.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
  contradict Ht_b ; apply (Hi 1%nat).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_n_Sn.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Rlt_dec => Hx1.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
   rewrite /Sup_fct /Lub_Rbar.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have H : x0 < x1.
    apply Rlt_trans with t.
    apply Rnot_lt_le in Ht_a ; case: Ht_a => Ht_a.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
    contradict Ht_a ; apply sym_not_eq, (Hi O).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hx1.
  move: (Rlt_not_eq _ _ H) ;
  case: Req_EM_T => // H0 _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: ex_lub_Rbar => l lub /=.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  apply lub ; exists t ; split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
  rewrite /Rmin /Rmax ; case: Rle_dec (proj1 Hsort) => // _ _ ;
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply Rnot_lt_le in Ht_a ; case: Ht_a => Ht_a.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
  contradict Ht_a ; apply sym_not_eq, (Hi O).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
  apply IH.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: (proj2 Hsort).
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Hx1.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Ht_b.
  move => j Hj ; apply (Hi (S j) (lt_n_S _ _ Hj)).
  apply head_unif_part.
  apply last_unif_part.

(* Partie 2 *)
(* * SF_lx ptd = unif_part a b n *)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  assert (forall g : R -> R -> R,
    let ptd := SF_seq_f2 g (unif_part a b n) in
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    pointed_subdiv ptd ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    Rabs (If - sign (b-a) * Riemann_sum f ptd) < eps2).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => g ptd Hptd.
  apply HIf.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Hptd.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_lx_f2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  suff : forall i, (S i < size (unif_part a b n))%nat ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    nth 0 (unif_part a b n) (S i) - nth 0 (unif_part a b n) i = (b-a)/(INR n + 1).
  elim: (unif_part a b n) => /= [ | h0 t IH].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => _ ; by apply Ealpha.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: t IH => /= [ | h1 t] IH Hnth.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Ealpha.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (seq_step _) with (Rmax (Rabs (h1 - h0)) (seq_step (h1::t))) by auto.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply (Rmax_case_strong (Rabs (h1 - h0))) => /= _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (Hnth O (lt_n_S _ _ (lt_O_Sn _))).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rabs_right.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Hn.
  apply Rle_ge, Rdiv_le_0_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rlt_le, Rgt_minus.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by intuition.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply IH => i Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply (Hnth (S i)), lt_n_S.
  move => i ; rewrite size_mkseq => Hi ; rewrite !nth_mkseq.
  rewrite S_INR ; field ; apply Rgt_not_eq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply SSR_leq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply SSR_leq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_0_Sn.
  rewrite -> Rmin_left by now apply Rlt_le.
  apply head_unif_part.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -nth_last SF_lx_f2.
  change (head 0 (unif_part a b n) :: behead (unif_part a b n))
    with (unif_part a b n).
  rewrite -> Rmax_right by now apply Rlt_le.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite size_mkseq nth_mkseq.
  simpl ssrnat.predn ; rewrite S_INR ;
  field ; apply Rgt_not_eq ; by intuition.
  simpl ; apply SSR_leq, le_refl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply lt_O_Sn.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: H => {HIf} HIf.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  assert (forall g1 g2 : R -> R -> R,
    let ptd1 := SF_seq_f2 g1 (unif_part a b n) in
    let ptd2 := SF_seq_f2 g2 (unif_part a b n) in
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    pointed_subdiv ptd1 -> pointed_subdiv ptd2 ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    Rabs (Riemann_sum f ptd1 - Riemann_sum f ptd2) < eps).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => g1 g2 ptd1 ptd2 H1 H2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  replace (Riemann_sum f ptd1 - Riemann_sum f ptd2) with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    ((If - sign (b - a) * Riemann_sum f ptd2) -
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      (If - sign (b - a) * Riemann_sum f ptd1)).
  apply Rle_lt_trans with (1 := Rabs_triang _ _).
  rewrite Rabs_Ropp (double_var eps) ; apply Rplus_lt_compat ;
  by apply HIf.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (IZR (Zpos xH)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  rewrite -> sign_eq_1 by exact: Rlt_Rminus.
  ring.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: H => {HIf} HIf.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /Riemann_sum in HIf.
(* * oublier If *)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  assert (forall g1 g2 : R -> R -> R,
    let ptd1 := SF_seq_f2 g1 (unif_part a b n) in
    let ptd2 := SF_seq_f2 g2 (unif_part a b n) in
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    pointed_subdiv ptd1 -> pointed_subdiv ptd2 ->
      Rabs
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
        (Riemann_sum (fun x => x) (SF_seq_f2 (fun x y => f (g1 x y) - f (g2 x y))
          (unif_part a b n))) < eps).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => g1 g2 ptd1 pdt2 H1 H2.
  replace (Riemann_sum _ _ : R) with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (Riemann_sum f (SF_seq_f2 g1 (unif_part a b n)) -
    Riemann_sum f (SF_seq_f2 g2 (unif_part a b n))).
  apply HIf.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: H1.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: H2.
  elim: (unif_part a b n) => /= [ | h0].
  rewrite /Riemann_sum /= /plus /zero /= ; ring.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => /= [ | h1 t] IH.
  rewrite /Riemann_sum /= /plus /zero /= ; ring.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  rewrite !(SF_cons_f2 _ h0) /= ; try by intuition.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite !Riemann_sum_cons /= -IH /plus /scal /= /mult /= ; ring.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move:H => {HIf} HIf.
(* * faire rentrer Rabs dans l'intégrale *)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  assert (forall g1 g2 : R -> R -> R,
    let ptd1 := SF_seq_f2 g1 (unif_part a b n) in
    let ptd2 := SF_seq_f2 g2 (unif_part a b n) in
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    pointed_subdiv ptd1 -> pointed_subdiv ptd2 ->
      Riemann_sum id
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      (SF_seq_f2 (fun x y : R => Rabs (f (g1 x y) - f (g2 x y)))
      (unif_part a b n)) < eps).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => g1 g2 ptd1 ptd2 H1 H2.
  set h1 := fun x y => match Rle_dec (f (g1 x y)) (f (g2 x y)) with
    | left _ => g2 x y | right _ => g1 x y end.
  set h2 := fun x y => match Rle_dec (f (g1 x y)) (f (g2 x y)) with
    | left _ => g1 x y | right _ => g2 x y end.
  replace (Riemann_sum id
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (SF_seq_f2 (fun x y : R => Rabs (f (g1 x y) - f (g2 x y)))
    (unif_part a b n))) with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (Riemann_sum id (SF_seq_f2 (fun x y : R => (f (h1 x y) - f (h2 x y)))
    (unif_part a b n))).
  apply Rle_lt_trans with (1 := Rle_abs _).
  apply HIf.
    revert ptd1 ptd2 H1 H2.
    elim: (unif_part a b n) (0) => [z /= _ _ | x0].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    move => i ; rewrite /SF_size /= => Hi ; by apply lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case => [ | x1 t] /= IH z H1 H2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    move => i ; rewrite /SF_size /= => Hi ; by apply lt_n_O in Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    move: H1 H2 ; rewrite !(SF_cons_f2 _ x0) /= ; try by intuition.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    move => H1 H2 ; case => [ | i] /= Hi.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    rewrite /h1 ; case: Rle_dec => //= _.
    apply (H2 O (lt_O_Sn _)).
    apply (H1 O (lt_O_Sn _)).
    apply (IH x0 (ptd_cons _ _ H1) (ptd_cons _ _ H2)).
    apply lt_S_n, Hi.
    revert ptd1 ptd2 H1 H2.
    elim: (unif_part a b n) (0) => [z /= _ _ | x0].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    move => i ; rewrite /SF_size /= => Hi ; by apply lt_n_O in Hi.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case => [ | x1 t] /= IH z H1 H2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    move => i ; rewrite /SF_size /= => Hi ; by apply lt_n_O in Hi.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    move: H1 H2 ; rewrite !(SF_cons_f2 _ x0) /= ; try by intuition.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    move => H1 H2 ; case => [ | i] /= Hi.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    rewrite /h2 ; case: Rle_dec => //= _.
    apply (H1 O (lt_O_Sn _)).
    apply (H2 O (lt_O_Sn _)).
    apply (IH x0 (ptd_cons _ _ H1) (ptd_cons _ _ H2)).
    apply lt_S_n, Hi.
  elim: (unif_part a b n) (0) => [x0 | x0].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite /Riemann_sum /= .
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => [ | x1 t] IH z.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by rewrite /Riemann_sum /= .
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  rewrite !(SF_cons_f2 _ x0) /= ; try by intuition.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !Riemann_sum_cons /=.
  apply f_equal2.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /h1 /h2 /id ; case: Rle_dec => H0.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rabs_left1.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
  simpl ; ring.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rle_minus.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rabs_right.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1))) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l1) (@opp (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) l2))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
  apply f_equal.
  simpl ; ring.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rgt_ge, Rgt_minus, Rnot_le_lt.
  by apply IH.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: H => {HIf} HIf.
(* * phi (g x y) = f (h x y) *)
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  assert (forall g : R -> R -> R,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (forall i j, (S i < size (unif_part a b n))%nat ->
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      (j < size (unif_part a b n))%nat ->
      g (nth 0 (unif_part a b n) i) (nth 0 (unif_part a b n) (S i))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      <> nth 0 (unif_part a b n) j) ->
    let ptd := SF_seq_f2 g (unif_part a b n) in
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    pointed_subdiv ptd ->
    Riemann_sum id
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (SF_seq_f2 (fun x y : R => Rabs (f (g x y) - phi (g x y)))
    (unif_part a b n)) < eps).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => g1 Hg1 ptd1 H1.
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /phi /sf_SF_val_fun ; case: Rle_dec (Rlt_le _ _ Hab) => //= _ _.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (unif_part_nat a b n) => Hp.
  set h := fun t => match Rle_dec a t with
    | right _ => t
    | left Ha => match Rle_dec t b with
      | right _ => t
      | left Hb => match Hp t (conj Ha Hb) with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
        | inleft H => (a + (INR (proj1_sig H) + /2) * (b - a) / (INR n + 1))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
        | inright _ => (a + (INR n + /2) * (b - a) / (INR n + 1))
      end
    end
  end.
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set g2 := fun x y => h (g1 x y).
(* Goal: Rle (@norm R_AbsRing V (@minus (NormedModule.AbelianGroup R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2))) (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) *)
(* Goal: Rlt (Rplus (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))))) (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@plus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2)))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
  set ptd2 := SF_seq_f2 g2 (unif_part a b n).
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have H2 : pointed_subdiv ptd2.
    move => i ; move: (H1 i) => {H1}.
    rewrite !SF_lx_f2 ; (try by apply lt_O_Sn) ;
    rewrite !SF_ly_f2 !SF_size_f2 size_mkseq.
    move => H1 Hi ; move: (H1 Hi) => {H1}.
    simpl in Hi.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite !nth_behead !(nth_pairmap 0).
    replace (nth 0 (0 :: unif_part a b n) (S i)) with
      (nth 0 (unif_part a b n) i) by auto.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    rewrite /g2 /h => {h g2 ptd2 ptd1} H1.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Rle_dec => Ha.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Rle_dec => Hb.
    case: Hp => [ [j [Ht Hj]] | Ht] ; simpl proj1_sig.
    suff Hij : j = i.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite Hij in Ht, Hj |- * => {j Hij}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite !nth_mkseq.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite S_INR.
    split ; simpl ; apply Rminus_le_0 ; field_simplify.
    rewrite Rdiv_1 ; apply Rdiv_le_0_compat.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite Rplus_comm -Rminus_le_0 ; exact: (Rlt_le _ _ Hab).
    generalize (pos_INR n) ; lra.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply Rgt_not_eq ; by intuition.
    rewrite Rdiv_1 ; apply Rdiv_le_0_compat.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite Rplus_comm -Rminus_le_0 ; exact: (Rlt_le _ _ Hab).
    generalize (pos_INR n) ; lra.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply Rgt_not_eq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; rewrite size_mkseq in Hi, Hj ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; rewrite size_mkseq in Hi, Hj ; by intuition.
    apply le_antisym ; apply not_lt.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    have Hij : nth 0 (unif_part a b n) j < nth 0 (unif_part a b n) (S i).
      apply Rle_lt_trans with
        (g1 (nth 0 (unif_part a b n) i) (nth 0 (unif_part a b n) (S i))).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply Ht.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
      case: (proj2 H1) => {H1} H1.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
      exact: H1.
      contradict H1 ; apply (Hg1 i (S i)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq ; by apply lt_n_S.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq ; by apply lt_n_S.
    contradict Hij.
    apply Rle_not_lt, sorted_incr.
    apply unif_part_sort, Rlt_le, Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (Rle_lt_trans _ _ _ (proj1 H1) (proj2 Ht)) => Hij.
    contradict Hij.
    apply Rle_not_lt, sorted_incr.
    apply unif_part_sort, Rlt_le, Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    rewrite size_mkseq ; by intuition.
    suff : i = n.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    move => ->.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite !nth_mkseq ?S_INR.
    split ; simpl ; apply Rminus_le_0 ; field_simplify.
    rewrite Rdiv_1 ; apply Rdiv_le_0_compat.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite Rplus_comm -Rminus_le_0 ; exact: (Rlt_le _ _ Hab).
    generalize (pos_INR n) ; lra.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply Rgt_not_eq ; by intuition.
    rewrite Rdiv_1 ; apply Rdiv_le_0_compat.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    rewrite Rplus_comm -Rminus_le_0 ; exact: (Rlt_le _ _ Hab).
    generalize (pos_INR n) ; lra.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply Rgt_not_eq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; by intuition.
    apply le_antisym ; apply not_lt.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    have Hij : nth 0 (unif_part a b n) i < nth 0 (unif_part a b n) (S n).
      apply Rle_lt_trans with
        (g1 (nth 0 (unif_part a b n) i) (nth 0 (unif_part a b n) (S i))).
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_down ptd b))) l1)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (@norm R_AbsRing V (@minus (ModuleSpace.AbelianGroup R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c b)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f (SF_cut_up ptd b))) l2)) (Rdiv (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (IZR (Zpos (xO xH)))) *)
      by apply H1.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
      case: (proj2 Ht) => {Ht} Ht.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
      exact: Ht.
      contradict Ht ; apply Hg1.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq ; by apply lt_n_S.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq ; by apply lt_n_Sn.
    contradict Hij.
    apply Rle_not_lt, sorted_incr.
    apply unif_part_sort, Rlt_le , Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    rewrite size_mkseq ; by intuition.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    have Hij : nth 0 (unif_part a b n) (n) < nth 0 (unif_part a b n) (S i).
      apply Rle_lt_trans with
        (g1 (nth 0 (unif_part a b n) i) (nth 0 (unif_part a b n) (S i))).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply Ht.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
      case: (proj2 H1) => {H1} H1.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
      exact: H1.
      contradict H1 ; apply Hg1.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq ; by intuition.
    contradict Hij.
    apply Rle_not_lt, sorted_incr.
    apply unif_part_sort, Rlt_le, Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    rewrite size_mkseq ; by intuition.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: H1.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: H1.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; rewrite size_mkseq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; rewrite size_mkseq ; by intuition.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (HIf g1 g2 H1 H2).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    replace (SF_seq_f2 (fun x y : R => Rabs (f (g1 x y) - SF_val_fun f a b n (g1 x y)))
     (unif_part a b n)) with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
     (SF_seq_f2 (fun x y : R => Rabs (f (g1 x y) - f (g2 x y)))
     (unif_part a b n)).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    have H0 : forall t, a <= t <= b -> SF_val_fun f a b n t = f (h t).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
      move => t Ht.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
      rewrite /h SF_val_fun_rw.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
      case: Ht => Ha Hb.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
      case: Rle_dec => // Ha'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
      case: Rle_dec => // Hb'.
      case: unif_part_nat => [ [i [Ht Hi]] | Ht] ;
      case: Hp {h g2 ptd2 H2} => [ [j [Ht' Hj]] | Ht'] ; simpl proj1_sig.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      apply (f_equal (fun i => f (a + (INR i + /2) * (b - a) / (INR n + 1)))).
      apply le_antisym ; apply not_lt.
      move: (Rle_lt_trans _ _ _ (proj1 Ht) (proj2 Ht')) => Hij ;
      contradict Hij.
      apply Rle_not_lt, sorted_incr.
      apply unif_part_sort, Rlt_le, Hab.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by intuition.
      move: (Rle_lt_trans _ _ _ (proj1 Ht') (proj2 Ht)) => Hij ;
      contradict Hij.
      apply Rle_not_lt, sorted_incr.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply unif_part_sort, Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by intuition.
      absurd (i < n)%nat.
      move: (Rle_lt_trans _ _ _ (proj1 Ht') (proj2 Ht)) => Hij ;
      contradict Hij.
      apply Rle_not_lt, sorted_incr.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply unif_part_sort, Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq in Hi ; by intuition.
      absurd (j < n)%nat.
      move: (Rle_lt_trans _ _ _ (proj1 Ht) (proj2 Ht')) => Hij ;
      contradict Hij.
      apply Rle_not_lt, sorted_incr.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by apply unif_part_sort, Rlt_le.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      rewrite size_mkseq in Hj ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
      by [].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /g2.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  have : forall i, (i < size (unif_part a b n))%nat ->
    a <= nth 0 (unif_part a b n) i <= b.
    move => i ; rewrite size_mkseq => Hi ; rewrite nth_mkseq.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    pattern b at 3 ; replace b with (a + (INR n + 1) * (b - a) / (INR n + 1)) by
      (field ; apply Rgt_not_eq ; intuition).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    pattern a at 1 ; replace a with (a + 0 * (b - a) / (INR n + 1)) by
      (field ; apply Rgt_not_eq ; intuition).
    apply Rgt_minus in Hab.
    split ; apply Rplus_le_compat_l ; repeat apply Rmult_le_compat_r ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    try by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    rewrite -S_INR ; apply le_INR ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply SSR_leq.
    revert ptd1 H1 ;
    elim: (unif_part a b n) => [ ptd1 H1 Hnth | x0 ].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case => [ | x1 s] IH ptd1 H1 Hnth.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
    revert ptd1 H1 ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    rewrite !(SF_cons_f2 _ x0) /= ; try by intuition.
    intro ;
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    apply (f_equal2 (fun x y => SF_cons (x0, Rabs (f (g1 x0 x1) - x)) y)).
    apply sym_equal, H0.
    move: (H1 O (lt_O_Sn _))
      (Hnth O (lt_O_Sn _)) (Hnth 1%nat (lt_n_S _ _ (lt_O_Sn _))) => /= ; intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rle_trans with x0.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rle_trans with x1.
    apply (IH (ptd_cons _ _ H1)).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    move => i Hi ; apply (Hnth (S i)) ; simpl in Hi |- * ; by apply lt_n_S.

(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: H => {HIf} HIf.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rabs_right.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
(* * dernière étape :-) *)
  replace (RiemannInt_SF psi) with
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (Riemann_sum id (SF_seq_f2 (fun x y : R => real (Sup_fct (fun t => Rabs (f t - phi t)) x y))
    (unif_part a b n))).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  set (F := fun s val => exists g : R -> R -> R,
    (forall (i j : nat),
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (S i < size s)%nat -> (j < size s)%nat
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      -> g (nth 0 s i) (nth 0 s (S i)) <> nth 0 s j) /\
    (let ptd := SF_seq_f2 g s in pointed_subdiv ptd) /\
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    Riemann_sum id (SF_seq_f2 (fun x y : R => Rabs (f (g x y) - phi (g x y)))
      s) = val).
  cut (is_lub (F (unif_part a b n)) (Riemann_sum id (SF_seq_f2
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (fun x y : R => real (Sup_fct (fun t : R => Rabs (f t - phi t)) x y))
    (unif_part a b n)))) => [ Hlub | ].

(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
  apply Hlub => val [g [Hnth [H0 Hval]]].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rlt_le ; rewrite -Hval.
  apply HIf.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: Hnth.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: H0.

  Focus 2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite StepFun_P30.
  replace (RiemannInt_SF psi2) with 0.
  rewrite Rmult_0_r Rplus_0_r /RiemannInt_SF SF_sup_subdiv SF_sup_subdiv_val ;
  case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
  elim: (unif_part a b n) (unif_part_sort a b n (Rlt_le _ _ Hab))
  => [ Hsort | x0 ].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => [ | x1 s] IH Hsort.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_cons_f2 /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Riemann_sum_cons /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Rmult_comm.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply f_equal, IH, Hsort.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: lt_O_Sn.
  rewrite /RiemannInt_SF ;
  case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (StepFun_P17 (StepFun_P1 psi2) psi2_ad).
  clear psi2_ad.
  revert psi2_ly ; elim: (unif_part a b n) => /= [ | x0].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => /= [ | x1 s] IH.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -IH ; ring.

  Focus 2.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite StepFun_P30.
  replace (RiemannInt_SF psi2) with 0.
  rewrite Rmult_0_r Rplus_0_r ;
  rewrite /RiemannInt_SF SF_sup_subdiv SF_sup_subdiv_val ;
  case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
  elim: (unif_part a b n) (unif_part_sort a b n (Rlt_le _ _ Hab))
    => [ Hsort /= | x0].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rge_refl.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => [ | x1 s] IH Hsort /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rge_refl.
  apply Rle_ge, Rplus_le_le_0_compat.
  apply Rmult_le_pos.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /Sup_fct /Lub_Rbar.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Req_EM_T => Hx0.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  by apply Rle_refl.
  case: ex_lub_Rbar ;
  case => [l | | ] [ub lub] /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply Rle_trans with (Rabs (f ((x0+x1)/2) - phi ((x0+x1)/2))).
  apply Rabs_pos.
  apply ub.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  exists ((x0+x1)/2) ; split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: forall (x : R) (_ : and (Rlt (Rmin (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))) x) (Rlt x (Rmax (@SF_h R s) (@last R (@SF_h R s) (@unzip1 R R (@SF_t R s)))))), @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /Rmin /Rmax ; case: Rle_dec (proj1 Hsort) => // _ _.
  pattern x1 at 3 ; replace x1 with ((x1 + x1)/2) by field.
  pattern x0 at 1 ; replace x0 with ((x0 + x0)/2) by field.
  split ; apply Rmult_lt_compat_r.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rinv_0_lt_compat, Rlt_R0_R2.
  apply Rplus_lt_compat_l ; by case: (proj1 Hsort).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply Rinv_0_lt_compat, Rlt_R0_R2.
  apply Rplus_lt_compat_r ; by case: (proj1 Hsort).
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  apply Rle_refl.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  apply Rle_refl.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  apply -> Rminus_le_0 ; apply Hsort.
  apply Rge_le, IH, Hsort.
  rewrite /RiemannInt_SF ;
  case: Rle_dec (Rlt_le _ _ Hab) => // _ _.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite (StepFun_P17 (StepFun_P1 psi2) psi2_ad).
  clear psi2_ad.
  revert psi2_ly ; elim: (unif_part a b n) => /= [ | x0].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => /= [ | x1 s] IH.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  rewrite -IH ; ring.

(* ** c'est la bonne borne sup *)

(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: Hfin.
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
  have : sorted Rlt (unif_part a b n).
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    apply sorted_nth => i.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite size_mkseq => Hi x0 ; rewrite !nth_mkseq.
    apply Rminus_gt ; rewrite S_INR ; field_simplify.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rdiv_1.
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) (Rmult (IZR (Zpos (xO (xO xH)))) (Rplus (Rplus M1 (IZR (Zpos xH))) (Rplus M2 (IZR (Zpos xH)))))) *)
(* Goal: Riemann_fine a c (fun x : @SF_seq R => @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f x))) *)
    apply Rdiv_lt_0_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    rewrite Rplus_comm ; by apply Rgt_minus.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply Rgt_not_eq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; by intuition.
  elim: (unif_part a b n) (unif_part_sort a b n (Rlt_le _ _ Hab))
    => [ Hle Hlt Hfin | x1].
  split ; rewrite /Riemann_sum /=.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => val [g [Hnth [Hptd Hval]]].
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  rewrite -Hval ; by apply Rle_refl.
  move => ub Hub ; apply: Hub.
  exists (fun _ _ => 0).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => i j Hi Hj ; by apply lt_n_O in Hi.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => ptd i Hi ; by apply lt_n_O in Hi.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case => [ | x2 s] IH Hle Hlt Hfin.
  split ; rewrite /Riemann_sum /=.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => val [g [Hnth [Hptd Hval]]].
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
  rewrite -Hval ; by apply Rle_refl.
  move => ub Hub ; apply: Hub.
  exists (fun _ _ => 0).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => i j Hi Hj.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  simpl in Hi ; by apply lt_S_n, lt_n_O in Hi.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => ptd i Hi ; by apply lt_n_O in Hi.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  rewrite SF_cons_f2 /= ; last by apply lt_O_Sn.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Riemann_sum_cons /=.
  set F0 := fun x =>
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    exists t, x1 < t < x2 /\ x = Rabs (f t - phi t) * (x2 - x1).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  set set_plus := fun (F : R -> Prop) (G : R -> Prop) (x : R) =>
    exists y, exists z, x = y + z /\ F y /\ G z.
  suff H0 : forall (x : R), F [:: x1, x2 & s] x
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    <-> (set_plus (F0) (F (x2::s))) x.
  cut (is_lub (set_plus (F0) (F (x2::s)))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (real (Sup_fct (fun t : R => Rabs (f t - phi t)) x1 x2) * (x2 - x1) +
    Riemann_sum id
    (SF_seq_f2
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (fun x y : R => real (Sup_fct (fun t : R => Rabs (f t - phi t)) x y))
    (x2 :: s)))) => [H1 | ].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => x Hx.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /plus /scal /= /mult /= Rmult_comm.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by apply H1, H0.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => ub Hub.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /plus /scal /= /mult /= Rmult_comm.
  apply H1 => x Hx ; by apply Hub, H0.
  suff H_F0 : is_lub (F0) (real (Sup_fct
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (fun t : R => Rabs (f t - phi t)) x1 x2) * (x2 - x1)).
  have Hfin0 : (forall i : nat,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (S i < size (x2 :: s))%nat ->
    is_finite
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (Sup_fct (fun t0 : R => Rabs (f t0 - phi t0)) (nth 0 (x2 :: s) i)
       (nth 0 (x2 :: s) (S i)))).
    move => i /= Hi ; move: (Hfin (S i) (lt_n_S _ _ Hi)) => /= {Hfin}.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].

(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: H_F0 (IH (proj2 Hle) (proj2 Hlt) Hfin0).

  move: (F0 (pos_div_2 eps)) (F (x2::s) (pos_div_2 eps))
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    (real (Sup_fct (fun t : R => Rabs (f t - phi t)) x1 x2) * (x2 - x1))
    (Riemann_sum id (SF_seq_f2 (fun x4 y : R =>
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      real (Sup_fct (fun t : R => Rabs (f t - phi t)) x4 y)) (x2 :: s))).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => F1 F2 l1 l2 Hl1 Hl2.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    move => _ [y [z [-> Hx]]].
    apply Rplus_le_compat.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hl1, Hx.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hl2, Hx.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move => ub Hub.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    replace ub with ((ub-l2) + l2) by ring.
    apply Rplus_le_compat_r.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    apply Hl1 => y Hy.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    replace y with (l2 + (y - l2)) by ring.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    replace (ub-l2) with ((ub - y) + (y - l2)) by ring.
    apply Rplus_le_compat_r.
(* Goal: Rlt (IZR Z0) (@RInt R_CompleteNormedModule (fun x : R => @minus (NormedModule.AbelianGroup R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) (g x) (f x)) a b) *)
    apply Hl2 => z Hz.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    replace z with ((y+z) - y) by ring.
    apply Rplus_le_compat_r.
    apply Hub.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    exists y ; exists z ; by intuition.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (Hfin O (lt_n_S _ _ (lt_O_Sn _))).
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite /Sup_fct /=.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (Rlt_not_eq _ _ (proj1 Hlt)).
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Req_EM_T => // Hx1 _.
  rewrite /Lub_Rbar ; case: ex_lub_Rbar ;
    case => [l | | ] [ub lub] ; simpl.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    move => _ [t [Ht ->]].
    apply Rmult_le_compat_r.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    apply -> Rminus_le_0 ; apply Hle.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    apply ub ; exists t ; split.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
    rewrite /Rmin /Rmax ; case: Rle_dec (proj1 Hle) => // _ _ ;
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move => b0 Hb0.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (Rgt_minus _ _ (proj1 Hlt)) => H1.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    replace b0 with ((b0 / (x2 - x1)) * (x2 - x1)) by
      (field ; by apply Rgt_not_eq).
    apply Rmult_le_compat_r.
    by apply Rlt_le.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    change (Rbar_le l (b0 / (x2 - x1))).
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    apply lub => _ [t [-> Ht]].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    replace (Rabs (f t - phi t)) with ((Rabs (f t - phi t) * (x2 - x1)) / (x2 - x1))
      by (field ; by apply Rgt_not_eq).
    apply Rmult_le_compat_r.
    by apply Rlt_le, Rinv_0_lt_compat.
    apply Hb0 ; exists t.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @ball_norm R_AbsRing V (@plus (NormedModule.AbelianGroup R_AbsRing V) l1 l2) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus c a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd)) *)
    move: Ht ; rewrite /Rmin /Rmax ; case: Rle_dec (proj1 Hle) => //.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].


(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by [].

(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x0))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    move => val ; split => Hval.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    case: Hval => g [Hnth [Hptd <-]] {val}.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite SF_cons_f2 /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Riemann_sum_cons /=.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    exists (Rabs (f (g x1 x2) - phi (g x1 x2)) * (x2 - x1)).
    exists (Riemann_sum id
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
      (SF_seq_f2 (fun x y : R => Rabs (f (g x y) - phi (g x y))) (x2 :: s))).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite Rmult_comm.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    exists (g x1 x2) ; split.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: (Hptd O) => /=.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    rewrite SF_size_f2 /= ; exact: lt_O_Sn.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case => Hx1.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case => Hx2.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    by split.
    contradict Hx2 ; apply (Hnth O 1%nat).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    simpl ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    simpl ; by intuition.
    contradict Hx1 ; apply sym_not_eq, (Hnth O O).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    simpl ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    simpl ; by intuition.

(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
    exists g.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move => i j Hi Hj.
    apply (Hnth (S i) (S j)).
    simpl ; apply lt_n_S, Hi.
    simpl ; apply lt_n_S, Hj.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: Hptd => /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite SF_cons_f2 /=.
    apply ptd_cons.
    apply lt_O_Sn.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
    exact: lt_O_Sn.

(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Hval => /= y Hy.
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    case: Hy => /= z [-> [F0y Fz]].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    case: F0y => t [Ht ->].
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
    case: Fz => g [Hnth [Hpdt <-]].
    set g0 := fun x y => match Req_EM_T x x1 with
      | left _ => match Req_EM_T y x2 with
        | left _ => t
        | right _ => g x y
      end
      | right _ => g x y
    end.
    exists g0.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
    split.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move => {val y z} i j Hi Hj.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
    rewrite /g0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Req_EM_T => Hx1'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: Req_EM_T => Hx2'.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: j Hj => /= [ | j] Hj.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rgt_not_eq, Ht.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    apply lt_S_n in Hj ; case: j Hj => /= [ | j] Hj.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Rlt_not_eq, Ht.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (proj2 Hle : sorted Rle (x2 :: s)).
    apply lt_S_n in Hj ; move: (proj2 Ht) ;
    elim: j x2 s Hj {IH Hle Hlt Hfin Hnth Hpdt F0 Ht g0 Hx2' Hx1' i Hi}
      => [ | i IH] x0 ; case => {x1} [ | x1 s] Hi Ht Hle ; simpl.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_irrefl in Hi.
    apply Rlt_not_eq, Rlt_le_trans with (1 := Ht).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hle.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply lt_n_O in Hi.
    apply (IH x1).
    by apply lt_S_n, Hi.
    apply Rlt_le_trans with (1 := Ht).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hle.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by apply Hle.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: i j Hi Hj Hx1' Hx2' => /= [ | i] j Hi Hj Hx1' Hx2'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: j Hj => /= [ | j] Hj.
    apply Rgt_not_eq, Rlt_le_trans with x2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply Rlt_trans with t ; by intuition.
    apply Rle_trans with (nth 0 (x2 :: s) i).
    apply (sorted_incr (x2 :: s) O i).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (ptd_sort _ Hpdt).
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    rewrite /SF_sorted SF_lx_f2 // ; by apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    simpl ; by intuition.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (Hpdt i).
    rewrite SF_size_f2 SF_lx_f2 ; (try by apply lt_O_Sn) ; rewrite SF_ly_f2 (nth_pairmap 0) /=.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
    move => H ; apply H.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; by intuition.
    apply Hnth.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
    simpl in Hi ; apply lt_S_n in Hi ;
    case: i Hi Hx1' => /= [ | i] Hi Hx1'.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by [].
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
    case: j Hj => /= [ | j] Hj.
    apply Rgt_not_eq, Rlt_le_trans with x2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply Rlt_trans with t ; by intuition.
    apply Rle_trans with (nth 0 (x2 :: s) i).
    apply (sorted_incr (x2 :: s) O i).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (ptd_sort _ Hpdt).
    by rewrite /SF_sorted SF_lx_f2 // ; apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    simpl ; by intuition.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
    move: (Hpdt i).
    rewrite SF_size_f2 SF_lx_f2 ; (try by apply lt_O_Sn) ; rewrite SF_ly_f2 (nth_pairmap 0) /=.
(* Goal: Rle (@norm R_AbsRing V (f x)) M *)
    move => H ; apply H.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    apply SSR_leq ; by intuition.
    apply Hnth.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
    by intuition.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move => ptd i Hi.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_size_f2 /= in Hi.
  rewrite SF_lx_f2 ; (try by apply lt_O_Sn) ; rewrite SF_ly_f2 nth_behead (nth_pairmap 0) /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  case: i Hi => /= [ | i] Hi ; rewrite /g0.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  move: (refl_equal x1) ; case: Req_EM_T => // _ _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  move: (refl_equal x2) ; case: Req_EM_T => // _ _.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  split ; apply Rlt_le ; by intuition.
  suff : (nth 0 (x2 :: s) i) <> x1.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  case: Req_EM_T => // _ _.
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (Hpdt i).
  rewrite SF_size_f2 SF_lx_f2 ; (try by apply lt_O_Sn) ; rewrite SF_ly_f2 nth_behead (nth_pairmap 0) /=.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  move => H ; apply H ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply SSR_leq ; by intuition.
  apply Rgt_not_eq, Rlt_le_trans with x2.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply Rlt_trans with t ; by intuition.
  apply (sorted_incr (x2 :: s) O i).
(* Goal: forall (_ : @ex_RInt U (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b) (_ : @ex_RInt V (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) a b), @ex_RInt (prod_NormedModule R_AbsRing U V) f a b *)
  move: (ptd_sort _ Hpdt).
  by rewrite /SF_sorted SF_lx_f2 // ; apply lt_O_Sn.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  simpl ; by intuition.
(* Goal: @continuous R_UniformSpace (NormedModule.UniformSpace R_AbsRing (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule)) f x *)
  apply SSR_leq ; by intuition.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite SF_cons_f2 /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite Riemann_sum_cons /=.
  apply f_equal2.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  rewrite /g0 ; move: (refl_equal x1) ; case: Req_EM_T => // _ _.
(* Goal: @eq (NormedModule.sort R_AbsRing V) (if Rlt_dec x (@fst R R x1) then @zero (NormedModule.AbelianGroup R_AbsRing V) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (if Rlt_dec x (@fst R R x1) then f (@snd R R x0) else @SF_fun_aux (NormedModule.sort R_AbsRing V) (@pair R (NormedModule.sort R_AbsRing V) (@SF_h R s) (f (@snd R R x1))) (@map (prod R R) (prod R (NormedModule.sort R_AbsRing V)) (fun x : prod R R => @pair R (NormedModule.sort R_AbsRing V) (@fst R R x) (f (@snd R R x))) (@SF_t R s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @eq (NormedModule.sort R_AbsRing V) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f s) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V)) x) *)
(* Goal: @SF_sorted R Rle s *)
  move: (refl_equal x2) ; case: Req_EM_T => // _ _.
(* Goal: @eq (Ring.sort R_Ring) (@mult R_Ring k (sign (Rminus b a))) (@mult R_Ring (sign (Rminus b a)) k) *)
(* Goal: @filterlim (@SF_seq R) (ModuleSpace.sort R_Ring (NormedModule.ModuleSpace R_AbsRing V)) (fun ptd : @SF_seq R => @scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) (sign (Rminus b a)) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f ptd))) (Riemann_fine a b) (@locally (NormedModule.UniformSpace R_AbsRing V) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing V) k If)) *)
  apply Rmult_comm.
  case: s Hlt {Hpdt IH Hle Hfin F0 Ht Hnth}
    => [ | x3 s] Hlt /=.
  apply refl_equal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !(SF_cons_f2 _ _ (x3 :: _)) /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !Riemann_sum_cons /=.
  apply f_equal2.
  rewrite /g0 /id ; move: (Rgt_not_eq _ _ (proj1 Hlt)) ;
  by case: Req_EM_T.
  elim: s (x2) x3 Hlt => [ | x4 s IH] x2' x3 Hlt.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: refl_equal.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !(SF_cons_f2 _ _ (x4 :: _)) /=.
(* Goal: Rlt (IZR Z0) (Rminus (@RInt R_CompleteNormedModule g a b) (@RInt R_CompleteNormedModule f a b)) *)
  rewrite !Riemann_sum_cons /=.
  apply f_equal2.
  rewrite /g0 ; move: (Rgt_not_eq _ _ (Rlt_trans _ _ _ (proj1 Hlt) (proj1 (proj2 Hlt)))) ;
  by case: Req_EM_T.
  apply (IH x3).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) lu lv) (pos eps) (@scal R_Ring (NormedModule.ModuleSpace R_AbsRing (prod_NormedModule R_AbsRing U V)) (sign (Rminus b a)) (@pair (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing U) (fun t : R => @fst (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd) (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) (fun t : R => @snd (NormedModule.sort R_AbsRing U) (NormedModule.sort R_AbsRing V) (f t)) ptd))) *)
  split.
  apply Rlt_trans with x2' ; apply Hlt.
  apply Hlt.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: lt_O_Sn.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: lt_O_Sn.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: lt_O_Sn.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: lt_O_Sn.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
  exact: lt_O_Sn.
Qed.

(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
Lemma RInt_Reals (f : R -> R) (a b : R) :
  forall pr, RInt f a b = @RiemannInt f a b pr.
Proof.
(* Goal: forall pr : Riemann_integrable f a b, @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing R_CompleteNormedModule)) (@RInt R_CompleteNormedModule f a b) (@RiemannInt f a b pr) *)
intros pr.
(* Goal: @eq (CompleteSpace.sort (CompleteNormedModule.CompleteSpace R_AbsRing R_CompleteNormedModule)) (@RInt R_CompleteNormedModule f a b) (@RiemannInt f a b pr) *)
apply is_RInt_unique.
(* Goal: @is_RInt (CompleteNormedModule.NormedModule R_AbsRing R_CompleteNormedModule) f a b (@RiemannInt f a b pr) *)
apply ex_RInt_Reals_aux_1.
Qed.

(** ** Theorems proved using standard library *)

Lemma ex_RInt_norm :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> R) a b, ex_RInt f a b ->
  ex_RInt (fun x => norm (f x)) a b.
Proof.
(* Goal: forall (f : forall _ : R, R) (a b : R) (_ : @ex_RInt R_NormedModule f a b), @ex_RInt R_NormedModule (fun x : R => @norm R_AbsRing R_NormedModule (f x)) a b *)
intros f a b If.
(* Goal: @ex_RInt R_NormedModule (fun x : R => @norm R_AbsRing R_NormedModule (f x)) a b *)
apply ex_RInt_Reals_1.
(* Goal: Riemann_integrable (fun x : R => @norm R_AbsRing R_NormedModule (f x)) a b *)
apply RiemannInt_P16.
(* Goal: Riemann_integrable f a b *)
now apply ex_RInt_Reals_0.
Qed.

Lemma abs_RInt_le :
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  forall (f : R -> R) a b,
(* Goal: @is_RInt V (@SF_fun (NormedModule.sort R_AbsRing V) (@SF_map R (NormedModule.sort R_AbsRing V) f (@SF_cons R x0 s)) (@zero (NormedModule.AbelianGroup R_AbsRing V))) (@SF_h R s) b (@Riemann_sum (NormedModule.ModuleSpace R_AbsRing V) f s) *)
  a <= b -> ex_RInt f a b ->
  Rabs (RInt f a b) <= RInt (fun t => Rabs (f t)) a b.
Proof.
intros f a b H1 If.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: (norm_RInt_le f (fun t : R => norm (f t)) a b).
exact H1.
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@left (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: Rle (IZR Z0) (if @is_left (Rle t a) (not (Rle t a)) (@right (Rle t a) (not (Rle t a)) H1) then IZR Z0 else if @is_left (Rle b t) (not (Rle b t)) (@right (Rle b t) (not (Rle b t)) H2) then IZR Z0 else f t) *)
(* Goal: @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (sign (Rminus b a)) (@Riemann_sum R_ModuleSpace (fun _ : R => IZR Z0) ptd)) (IZR Z0) *)
(* Goal: forall (x : R) (_ : and (Rlt (Rmin a b) x) (Rlt x (Rmax a b))), @eq (NormedModule.sort R_AbsRing R_NormedModule) (f x) (f' x) *)
move => x _ ; by apply Rle_refl.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
exact: RInt_correct.
(* Goal: Rle (@RInt R_CompleteNormedModule f a b) (@RInt R_CompleteNormedModule g a b) *)
apply: RInt_correct.
(* Goal: @is_RInt R_NormedModule f a b (@RiemannInt f a b pr) *)
exact: ex_RInt_norm.
Qed.
