Require Import erl_prog_spec.

Definition type_LF_157 :=  PLAN ->  nat ->  nat ->  nat ->  nat -> (Prop * (List.list term)).

Definition F_157 : type_LF_157:= (fun   u1 u2 u3 _ _ => ((erl (insIn u1 u2 u3)) = u3, (Term id_erl ((Term id_insIn ((model_PLAN u1):: (model_nat u2):: (model_nat u3)::nil))::nil))::(model_nat u3)::nil)).
Definition F_169 : type_LF_157:= (fun    _ u2 u3 _ _ => ((erl (Cons (C u2 u3) Nil)) = u3, (Term id_erl ((Term id_Cons ((Term id_C ((model_nat u2):: (model_nat u3)::nil)):: (Term id_Nil nil)::nil))::nil))::(model_nat u3)::nil)).
Definition F_175 : type_LF_157:= (fun   u6 u3 u8 u9 _ => ((le (er (C u8 u9)) u3) = true -> (erl (insIn u6 (time (C u8 u9)) u3)) = u3, (Term id_le ((Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::(Term id_true nil)::(Term id_erl ((Term id_insIn ((model_PLAN u6):: (Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::nil))::(model_nat u3)::nil)).
Definition F_181 : type_LF_157:= (fun   u6 u2 u3 u8 u9 => ((le (er (C u8 u9)) u3) = false -> (erl (Cons (C u2 u3) (Cons (C u8 u9) u6))) = u3, (Term id_le ((Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::(Term id_false nil)::(Term id_erl ((Term id_Cons ((Term id_C ((model_nat u2):: (model_nat u3)::nil)):: (Term id_Cons ((Term id_C ((model_nat u8):: (model_nat u9)::nil)):: (model_PLAN u6)::nil))::nil))::nil))::(model_nat u3)::nil)).
Definition F_184 : type_LF_157:= (fun    _ u2 u3 _ _ => ((er (C u2 u3)) = u3, (Term id_er ((Term id_C ((model_nat u2):: (model_nat u3)::nil))::nil))::(model_nat u3)::nil)).
Definition F_193 : type_LF_157:= (fun    _ u3 _ _ _ => (u3 = u3, (model_nat u3)::(model_nat u3)::nil)).
Definition F_187 : type_LF_157:= (fun   u6 u3 u8 u9 _ => ((le u9 u3) = true -> (erl (insIn u6 (time (C u8 u9)) u3)) = u3, (Term id_le ((model_nat u9):: (model_nat u3)::nil))::(Term id_true nil)::(Term id_erl ((Term id_insIn ((model_PLAN u6):: (Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::nil))::(model_nat u3)::nil)).
Definition F_190 : type_LF_157:= (fun    _ u2 u3 u8 u9 => ((le (er (C u8 u9)) u3) = false -> (er (C u2 u3)) = u3, (Term id_le ((Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::(Term id_false nil)::(Term id_er ((Term id_C ((model_nat u2):: (model_nat u3)::nil))::nil))::(model_nat u3)::nil)).
Definition F_199 : type_LF_157:= (fun    _ u3 u8 u9 _ => ((le (er (C u8 u9)) u3) = false -> u3 = u3, (Term id_le ((Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::(Term id_false nil)::(model_nat u3)::(model_nat u3)::nil)).

Definition LF_157 := [F_157, F_169, F_175, F_181, F_184, F_193, F_187, F_190, F_199].

Function f_157 (u1: PLAN) (u2: nat) (u3: nat) {struct u1} : PLAN :=
 match u1, u2, u3 with
| Nil, _, _ => Nil
| (Cons (C u8 u9) u6), _, _ => Nil
end.

Lemma main_157 : forall F, In F LF_157 -> forall u1, forall u2, forall u3, forall u4, forall u5, (forall F', In F' LF_157 -> forall e1, forall e2, forall e3, forall e4, forall e5, less (snd (F' e1 e2 e3 e4 e5)) (snd (F u1 u2 u3 u4 u5)) -> fst (F' e1 e2 e3 e4 e5)) -> fst (F u1 u2 u3 u4 u5).
Proof.
intros F HF u1 u2 u3 u4 u5; case_In HF; intro Hind.

	(* GENERATE on [ 157 ] *)

rename u1 into _u1. rename u2 into _u2. rename u3 into _u3. rename u4 into d_u4. rename u5 into d_u5.
rename _u1 into u1. rename _u2 into u2. rename _u3 into u3.

revert Hind.

pattern u1, u2, u3, (f_157 u1 u2 u3). apply f_157_ind.

(* case [ 169 ] *)

intros _u1 _u2 _u3.  intro eq_1. intro. intro Heq2. rewrite <- Heq2. intro. intro Heq3. rewrite <- Heq3.  intro HFabs0.
assert (Hind := HFabs0 F_169). clear HFabs0.
assert (HFabs0 : fst (F_169 Nil _u2 _u3 0 0)).
apply Hind. trivial_in 1. unfold snd. unfold F_169. unfold F_157. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_157. unfold F_169.
auto.

intros _u1 _u2 _u3. intro u8. intro u9. intro u6.  intro eq_1. intro. intro Heq2. rewrite <- Heq2. intro. intro Heq3. rewrite <- Heq3.  intro HFabs0.
case_eq (le (er (C u8 u9)) _u3); [intro H | intro H].

(* case [ 175 ] *)

assert (Hind := HFabs0 F_175). clear HFabs0.
assert (HFabs0 : fst (F_175 u6 _u3 u8 u9 0)).
apply Hind. trivial_in 2. unfold snd. unfold F_175. unfold F_157. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_157. unfold F_175. simpl in H. repeat(simpl; rewrite H). repeat(simpl in HFabs0; rewrite H in HFabs0). try (auto || (intro H0; contradict H0)).
auto.

(* case [ 181 ] *)

assert (Hind := HFabs0 F_181). clear HFabs0.
assert (HFabs0 : fst (F_181 u6 _u2 _u3 u8 u9)).
apply Hind. trivial_in 3. unfold snd. unfold F_181. unfold F_157. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_157. unfold F_181. simpl in H. repeat(simpl; rewrite H). repeat(simpl in HFabs0; rewrite H in HFabs0). try (auto || (intro H0; contradict H0)).
auto.

	(* REWRITING on [ 169 ] *)

rename u1 into d_u1. rename u2 into _u2. rename u3 into _u3. rename u4 into d_u4. rename u5 into d_u5.
rename _u2 into u2. rename _u3 into u3.
assert (Res := Hind F_184). clear Hind.
assert (HFabs1 : fst (F_184 Nil u2 u3 0 0)).
apply Res. trivial_in 4. unfold snd. unfold F_184. unfold F_169. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_169. unfold fst in HFabs1. unfold F_184 in HFabs1.
pattern (C u2 u3), Nil. simpl (erl _). cbv beta.
 simpl. auto.

	(* REWRITING on [ 175 ] *)

rename u1 into _u6. rename u2 into _u3. rename u3 into _u8. rename u4 into _u9. rename u5 into d_u5.
rename _u6 into u6. rename _u3 into u3. rename _u8 into u8. rename _u9 into u9.
assert (Res := Hind F_187). clear Hind.
assert (HFabs1 : fst (F_187 u6 u3 u8 u9 0)).
apply Res. trivial_in 6. unfold snd. unfold F_187. unfold F_175. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_175. unfold fst in HFabs1. unfold F_187 in HFabs1.
pattern u8, u9. simpl (er _). cbv beta.
 simpl. auto.

	(* REWRITING on [ 181 ] *)

rename u1 into _u6. rename u2 into _u2. rename u3 into _u3. rename u4 into _u8. rename u5 into _u9.
rename _u6 into u6. rename _u2 into u2. rename _u3 into u3. rename _u8 into u8. rename _u9 into u9.
assert (Res := Hind F_190). clear Hind.
assert (HFabs1 : fst (F_190 Nil u2 u3 u8 u9)).
apply Res. trivial_in 7. unfold snd. unfold F_190. unfold F_181. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_181. unfold fst in HFabs1. unfold F_190 in HFabs1.
pattern (C u2 u3), (Cons (C u8 u9) u6). simpl (erl _). cbv beta.
 simpl. auto.

	(* REWRITING on [ 184 ] *)

rename u1 into d_u1. rename u2 into _u2. rename u3 into _u3. rename u4 into d_u4. rename u5 into d_u5.
rename _u2 into u2. rename _u3 into u3.
assert (Res := Hind F_193). clear Hind.
assert (HFabs1 : fst (F_193 Nil u3 0 0 0)).
apply Res. trivial_in 5. unfold snd. unfold F_193. unfold F_184. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_184. unfold fst in HFabs1. unfold F_193 in HFabs1.
pattern u2, u3. simpl (er _). cbv beta.
 simpl. auto.

	(* TAUTOLOGY on [ 193 ] *)

unfold fst. unfold F_193.
auto.

	(* REWRITING on [ 187 ] *)

rename u1 into _u6. rename u2 into _u3. rename u3 into _u8. rename u4 into _u9. rename u5 into d_u5.
rename _u6 into u6. rename _u3 into u3. rename _u8 into u8. rename _u9 into u9.
assert (Res := Hind F_157). clear Hind.
assert (HFabs1 : fst (F_157 u6 u8 u3 0 0)).
apply Res. trivial_in 0. unfold snd. unfold F_157. unfold F_187. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_187. unfold fst in HFabs1. unfold F_157 in HFabs1.
pattern u8, u9. simpl (time _). cbv beta.
 simpl. auto.

	(* REWRITING on [ 190 ] *)

rename u1 into d_u1. rename u2 into _u2. rename u3 into _u3. rename u4 into _u8. rename u5 into _u9.
rename _u2 into u2. rename _u3 into u3. rename _u8 into u8. rename _u9 into u9.
assert (Res := Hind F_199). clear Hind.
assert (HFabs1 : fst (F_199 Nil u3 u8 u9 0)).
apply Res. trivial_in 8. unfold snd. unfold F_199. unfold F_190. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_190. unfold fst in HFabs1. unfold F_199 in HFabs1.
pattern u2, u3. simpl (er _). cbv beta.
 simpl. auto.

	(* TAUTOLOGY on [ 199 ] *)

unfold fst. unfold F_199.
auto.

Qed.

(* the set of all formula instances from the proof *)
Definition S_157 := fun f => exists F, In F LF_157 /\ exists e1, exists e2, exists e3, exists e4, exists e5, f = F e1 e2 e3 e4 e5.

Theorem all_true_157: forall F, In F LF_157 -> forall u1: PLAN, forall u2: nat, forall u3: nat, forall u4: nat, forall u5: nat, fst (F u1 u2  u3  u4  u5).
Proof.
let n := constr:(5) in
let p := constr:(S(S(n))) in
intros;
let G := fresh "G" in
let x := fresh "x" in
apply wf_subset with (R:=@snd_rpo_mul P Prop max_size) (S:=S_157);
[(* 1 *) apply wf_snd_rpo_mul, prec_wf
|(* 2 *) idtac
|(* 3 *) eexists; split; [ eassumption | idtac]; do_nat n ltac:(eexists); reflexivity
];

intros x G;
do_nat p ltac:(elim G; intro; clear G; intro G);
rewrite G in * |- *; clear G; clear x;
intro G;
apply main_157;
 [assumption | idtac];
intros;
apply G;
 [ idtac | assumption ];
eexists; split;
 [idtac | do_nat n ltac:(eexists); reflexivity];
assumption.
Qed.

Theorem true_157: forall (u1: PLAN) (u2: nat) (u3: nat), (erl (insIn u1 u2 u3)) = u3.
Proof.
do 3 intro.
apply (all_true_157 F_157);
 (trivial_in 0) ||
 (repeat constructor).
Qed.

Definition type_LF_203 :=  PLAN ->  nat ->  nat ->  nat ->  nat -> (Prop * (List.list term)).

Definition F_203 : type_LF_203:= (fun   u1 u2 u3 _ _ => ((erl (insAt u1 u2 u3)) = u3, (Term id_erl ((Term id_insAt ((model_PLAN u1):: (model_nat u2):: (model_nat u3)::nil))::nil))::(model_nat u3)::nil)).
Definition F_216 : type_LF_203:= (fun    _ u2 u3 _ _ => ((erl (Cons (C u2 u3) Nil)) = u3, (Term id_erl ((Term id_Cons ((Term id_C ((model_nat u2):: (model_nat u3)::nil)):: (Term id_Nil nil)::nil))::nil))::(model_nat u3)::nil)).
Definition F_222 : type_LF_203:= (fun   u6 u2 u3 u8 u9 => ((le (time (C u8 u9)) u2) = true -> (erl (Cons (C u2 u3) (Cons (C u8 u9) u6))) = u3, (Term id_le ((Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u2)::nil))::(Term id_true nil)::(Term id_erl ((Term id_Cons ((Term id_C ((model_nat u2):: (model_nat u3)::nil)):: (Term id_Cons ((Term id_C ((model_nat u8):: (model_nat u9)::nil)):: (model_PLAN u6)::nil))::nil))::nil))::(model_nat u3)::nil)).
Definition F_228 : type_LF_203:= (fun   u6 u2 u3 u8 u9 => ((le (time (C u8 u9)) u2) = false -> (erl (insAt u6 u2 u3)) = u3, (Term id_le ((Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u2)::nil))::(Term id_false nil)::(Term id_erl ((Term id_insAt ((model_PLAN u6):: (model_nat u2):: (model_nat u3)::nil))::nil))::(model_nat u3)::nil)).
Definition F_231 : type_LF_203:= (fun    _ u2 u3 _ _ => ((er (C u2 u3)) = u3, (Term id_er ((Term id_C ((model_nat u2):: (model_nat u3)::nil))::nil))::(model_nat u3)::nil)).
Definition F_240 : type_LF_203:= (fun    _ u3 _ _ _ => (u3 = u3, (model_nat u3)::(model_nat u3)::nil)).
Definition F_234 : type_LF_203:= (fun    _ u2 u3 u8 u9 => ((le (time (C u8 u9)) u2) = true -> (er (C u2 u3)) = u3, (Term id_le ((Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u2)::nil))::(Term id_true nil)::(Term id_er ((Term id_C ((model_nat u2):: (model_nat u3)::nil))::nil))::(model_nat u3)::nil)).
Definition F_243 : type_LF_203:= (fun    _ u2 u3 u8 _ => ((le u8 u2) = true -> (er (C u2 u3)) = u3, (Term id_le ((model_nat u8):: (model_nat u2)::nil))::(Term id_true nil)::(Term id_er ((Term id_C ((model_nat u2):: (model_nat u3)::nil))::nil))::(model_nat u3)::nil)).
Definition F_246 : type_LF_203:= (fun    _ u2 u3 u8 _ => ((le u8 u2) = true -> u3 = u3, (Term id_le ((model_nat u8):: (model_nat u2)::nil))::(Term id_true nil)::(model_nat u3)::(model_nat u3)::nil)).

Definition LF_203 := [F_203, F_216, F_222, F_228, F_231, F_240, F_234, F_243, F_246].

Function f_203 (u1: PLAN) (u2: nat) (u3: nat) {struct u1} : PLAN :=
 match u1, u2, u3 with
| Nil, _, _ => Nil
| (Cons (C u8 u9) u6), _, _ => Nil
end.

Lemma main_203 : forall F, In F LF_203 -> forall u1, forall u2, forall u3, forall u4, forall u5, (forall F', In F' LF_203 -> forall e1, forall e2, forall e3, forall e4, forall e5, less (snd (F' e1 e2 e3 e4 e5)) (snd (F u1 u2 u3 u4 u5)) -> fst (F' e1 e2 e3 e4 e5)) -> fst (F u1 u2 u3 u4 u5).
Proof.
intros F HF u1 u2 u3 u4 u5; case_In HF; intro Hind.

	(* GENERATE on [ 203 ] *)

rename u1 into _u1. rename u2 into _u2. rename u3 into _u3. rename u4 into d_u4. rename u5 into d_u5.
rename _u1 into u1. rename _u2 into u2. rename _u3 into u3.

revert Hind.

pattern u1, u2, u3, (f_203 u1 u2 u3). apply f_203_ind.

(* case [ 216 ] *)

intros _u1 _u2 _u3.  intro eq_1. intro. intro Heq2. rewrite <- Heq2. intro. intro Heq3. rewrite <- Heq3.  intro HFabs0.
assert (Hind := HFabs0 F_216). clear HFabs0.
assert (HFabs0 : fst (F_216 Nil _u2 _u3 0 0)).
apply Hind. trivial_in 1. unfold snd. unfold F_216. unfold F_203. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_203. unfold F_216.
auto.

intros _u1 _u2 _u3. intro u8. intro u9. intro u6.  intro eq_1. intro. intro Heq2. rewrite <- Heq2. intro. intro Heq3. rewrite <- Heq3.  intro HFabs0.
case_eq (le (time (C u8 u9)) _u2); [intro H | intro H].

(* case [ 222 ] *)

assert (Hind := HFabs0 F_222). clear HFabs0.
assert (HFabs0 : fst (F_222 u6 _u2 _u3 u8 u9)).
apply Hind. trivial_in 2. unfold snd. unfold F_222. unfold F_203. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_203. unfold F_222. simpl in H. repeat(simpl; rewrite H). repeat(simpl in HFabs0; rewrite H in HFabs0). try (auto || (intro H0; contradict H0)).
auto.

(* case [ 228 ] *)

assert (Hind := HFabs0 F_228). clear HFabs0.
assert (HFabs0 : fst (F_228 u6 _u2 _u3 u8 u9)).
apply Hind. trivial_in 3. unfold snd. unfold F_228. unfold F_203. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_203. unfold F_228. simpl in H. repeat(simpl; rewrite H). repeat(simpl in HFabs0; rewrite H in HFabs0). try (auto || (intro H0; contradict H0)).
auto.

	(* REWRITING on [ 216 ] *)

rename u1 into d_u1. rename u2 into _u2. rename u3 into _u3. rename u4 into d_u4. rename u5 into d_u5.
rename _u2 into u2. rename _u3 into u3.
assert (Res := Hind F_231). clear Hind.
assert (HFabs1 : fst (F_231 Nil u2 u3 0 0)).
apply Res. trivial_in 4. unfold snd. unfold F_231. unfold F_216. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_216. unfold fst in HFabs1. unfold F_231 in HFabs1.
pattern (C u2 u3), Nil. simpl (erl _). cbv beta.
 simpl. auto.

	(* REWRITING on [ 222 ] *)

rename u1 into _u6. rename u2 into _u2. rename u3 into _u3. rename u4 into _u8. rename u5 into _u9.
rename _u6 into u6. rename _u2 into u2. rename _u3 into u3. rename _u8 into u8. rename _u9 into u9.
assert (Res := Hind F_234). clear Hind.
assert (HFabs1 : fst (F_234 Nil u2 u3 u8 u9)).
apply Res. trivial_in 6. unfold snd. unfold F_234. unfold F_222. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_222. unfold fst in HFabs1. unfold F_234 in HFabs1.
pattern (C u2 u3), (Cons (C u8 u9) u6). simpl (erl _). cbv beta.
 simpl. auto.

	(* REWRITING on [ 228 ] *)

rename u1 into _u6. rename u2 into _u2. rename u3 into _u3. rename u4 into _u8. rename u5 into _u9.
rename _u6 into u6. rename _u2 into u2. rename _u3 into u3. rename _u8 into u8. rename _u9 into u9.
assert (Res := Hind F_203). clear Hind.
assert (HFabs1 : fst (F_203 u6 u2 u3 0 0)).
apply Res. trivial_in 0. unfold snd. unfold F_203. unfold F_228. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_228. unfold fst in HFabs1. unfold F_203 in HFabs1.
pattern u8, u9. simpl (time _). cbv beta.
 simpl. auto.

	(* REWRITING on [ 231 ] *)

rename u1 into d_u1. rename u2 into _u2. rename u3 into _u3. rename u4 into d_u4. rename u5 into d_u5.
rename _u2 into u2. rename _u3 into u3.
assert (Res := Hind F_240). clear Hind.
assert (HFabs1 : fst (F_240 Nil u3 0 0 0)).
apply Res. trivial_in 5. unfold snd. unfold F_240. unfold F_231. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_231. unfold fst in HFabs1. unfold F_240 in HFabs1.
pattern u2, u3. simpl (er _). cbv beta.
 simpl. auto.

	(* TAUTOLOGY on [ 240 ] *)

unfold fst. unfold F_240.
auto.

	(* REWRITING on [ 234 ] *)

rename u1 into d_u1. rename u2 into _u2. rename u3 into _u3. rename u4 into _u8. rename u5 into _u9.
rename _u2 into u2. rename _u3 into u3. rename _u8 into u8. rename _u9 into u9.
assert (Res := Hind F_243). clear Hind.
assert (HFabs1 : fst (F_243 Nil u2 u3 u8 0)).
apply Res. trivial_in 7. unfold snd. unfold F_243. unfold F_234. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_234. unfold fst in HFabs1. unfold F_243 in HFabs1.
pattern u8, u9. simpl (time _). cbv beta.
 simpl. auto.

	(* REWRITING on [ 243 ] *)

rename u1 into d_u1. rename u2 into _u2. rename u3 into _u3. rename u4 into _u8. rename u5 into d_u5.
rename _u2 into u2. rename _u3 into u3. rename _u8 into u8.
assert (Res := Hind F_246). clear Hind.
assert (HFabs1 : fst (F_246 Nil u2 u3 u8 0)).
apply Res. trivial_in 8. unfold snd. unfold F_246. unfold F_243. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_243. unfold fst in HFabs1. unfold F_246 in HFabs1.
pattern u2, u3. simpl (er _). cbv beta.
 simpl. auto.

	(* TAUTOLOGY on [ 246 ] *)

unfold fst. unfold F_246.
auto.

Qed.

(* the set of all formula instances from the proof *)
Definition S_203 := fun f => exists F, In F LF_203 /\ exists e1, exists e2, exists e3, exists e4, exists e5, f = F e1 e2 e3 e4 e5.

Theorem all_true_203: forall F, In F LF_203 -> forall u1: PLAN, forall u2: nat, forall u3: nat, forall u4: nat, forall u5: nat, fst (F u1 u2  u3  u4  u5).
Proof.
let n := constr:(5) in
let p := constr:(S(S(n))) in
intros;
let G := fresh "G" in
let x := fresh "x" in
apply wf_subset with (R:=@snd_rpo_mul P Prop max_size) (S:=S_203);
[(* 1 *) apply wf_snd_rpo_mul, prec_wf
|(* 2 *) idtac
|(* 3 *) eexists; split; [ eassumption | idtac]; do_nat n ltac:(eexists); reflexivity
];

intros x G;
do_nat p ltac:(elim G; intro; clear G; intro G);
rewrite G in * |- *; clear G; clear x;
intro G;
apply main_203;
 [assumption | idtac];
intros;
apply G;
 [ idtac | assumption ];
eexists; split;
 [idtac | do_nat n ltac:(eexists); reflexivity];
assumption.
Qed.

Theorem true_203: forall (u1: PLAN) (u2: nat) (u3: nat), (erl (insAt u1 u2 u3)) = u3.
Proof.
do 3 intro.
apply (all_true_203 F_203);
 (trivial_in 0) ||
 (repeat constructor).
Qed.

Definition type_LF_251 :=  PLAN ->  nat ->  nat ->  nat ->  nat -> (Prop * (List.list term)).

Definition F_251 : type_LF_251:= (fun   u1 u2 u3 _ _ => ((erl (prog u1 u2 u3)) = (erl u1), (Term id_erl ((Term id_prog ((model_PLAN u1):: (model_nat u2):: (model_nat u3)::nil))::nil))::(Term id_erl ((model_PLAN u1)::nil))::nil)).
Definition F_265 : type_LF_251:= (fun    _  _ _ _ _ => ((erl Nil) = (erl Nil), (Term id_erl ((Term id_Nil nil)::nil))::(Term id_erl ((Term id_Nil nil)::nil))::nil)).
Definition F_271 : type_LF_251:= (fun   u4 u2 u3 u8 u9 => ((le (progAt (prog u4 u2 u3) (plus (time (C u8 u9)) u3)) (er (C u8 u9))) = true -> (erl (insAt (prog u4 u2 u3) (plus (time (C u8 u9)) u3) (er (C u8 u9)))) = (erl (Cons (C u8 u9) u4)), (Term id_le ((Term id_progAt ((Term id_prog ((model_PLAN u4):: (model_nat u2):: (model_nat u3)::nil)):: (Term id_plus ((Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::nil)):: (Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::nil))::(Term id_true nil)::(Term id_erl ((Term id_insAt ((Term id_prog ((model_PLAN u4):: (model_nat u2):: (model_nat u3)::nil)):: (Term id_plus ((Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil)):: (Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::nil))::nil))::(Term id_erl ((Term id_Cons ((Term id_C ((model_nat u8):: (model_nat u9)::nil)):: (model_PLAN u4)::nil))::nil))::nil)).
Definition F_277 : type_LF_251:= (fun   u4 u2 u3 u8 u9 => ((le (progAt (prog u4 u2 u3) (plus (time (C u8 u9)) u3)) (er (C u8 u9))) = false -> (erl (insIn (prog u4 u2 u3) (plus (time (C u8 u9)) u2) (er (C u8 u9)))) = (erl (Cons (C u8 u9) u4)), (Term id_le ((Term id_progAt ((Term id_prog ((model_PLAN u4):: (model_nat u2):: (model_nat u3)::nil)):: (Term id_plus ((Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::nil)):: (Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::nil))::(Term id_false nil)::(Term id_erl ((Term id_insIn ((Term id_prog ((model_PLAN u4):: (model_nat u2):: (model_nat u3)::nil)):: (Term id_plus ((Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u2)::nil)):: (Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::nil))::nil))::(Term id_erl ((Term id_Cons ((Term id_C ((model_nat u8):: (model_nat u9)::nil)):: (model_PLAN u4)::nil))::nil))::nil)).
Definition F_280 : type_LF_251:= (fun   u4 u2 u3 u8 u9 => ((le (progAt (prog u4 u2 u3) (plus (time (C u8 u9)) u3)) (er (C u8 u9))) = true -> (er (C u8 u9)) = (erl (Cons (C u8 u9) u4)), (Term id_le ((Term id_progAt ((Term id_prog ((model_PLAN u4):: (model_nat u2):: (model_nat u3)::nil)):: (Term id_plus ((Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::nil)):: (Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::nil))::(Term id_true nil)::(Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::(Term id_erl ((Term id_Cons ((Term id_C ((model_nat u8):: (model_nat u9)::nil)):: (model_PLAN u4)::nil))::nil))::nil)).
Definition F_286 : type_LF_251:= (fun   u4 u2 u3 u8 u9 => ((le (progAt (prog u4 u2 u3) (plus (time (C u8 u9)) u3)) (er (C u8 u9))) = true -> (er (C u8 u9)) = (er (C u8 u9)), (Term id_le ((Term id_progAt ((Term id_prog ((model_PLAN u4):: (model_nat u2):: (model_nat u3)::nil)):: (Term id_plus ((Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::nil)):: (Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::nil))::(Term id_true nil)::(Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::(Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::nil)).
Definition F_283 : type_LF_251:= (fun   u4 u2 u3 u8 u9 => ((le (progAt (prog u4 u2 u3) (plus (time (C u8 u9)) u3)) (er (C u8 u9))) = false -> (er (C u8 u9)) = (erl (Cons (C u8 u9) u4)), (Term id_le ((Term id_progAt ((Term id_prog ((model_PLAN u4):: (model_nat u2):: (model_nat u3)::nil)):: (Term id_plus ((Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::nil)):: (Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::nil))::(Term id_false nil)::(Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::(Term id_erl ((Term id_Cons ((Term id_C ((model_nat u8):: (model_nat u9)::nil)):: (model_PLAN u4)::nil))::nil))::nil)).
Definition F_289 : type_LF_251:= (fun   u4 u2 u3 u8 u9 => ((le (progAt (prog u4 u2 u3) (plus (time (C u8 u9)) u3)) (er (C u8 u9))) = false -> (er (C u8 u9)) = (er (C u8 u9)), (Term id_le ((Term id_progAt ((Term id_prog ((model_PLAN u4):: (model_nat u2):: (model_nat u3)::nil)):: (Term id_plus ((Term id_time ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil)):: (model_nat u3)::nil))::nil)):: (Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::nil))::(Term id_false nil)::(Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::(Term id_er ((Term id_C ((model_nat u8):: (model_nat u9)::nil))::nil))::nil)).

Definition LF_251 := [F_251, F_265, F_271, F_277, F_280, F_286, F_283, F_289].

Function f_251 (u1: PLAN) (u2: nat) (u3: nat) {struct u1} : PLAN :=
 match u1, u2, u3 with
| Nil, _, _ => Nil
| (Cons (C u8 u9) u4), _, _ => Nil
end.

Lemma main_251 : forall F, In F LF_251 -> forall u1, forall u2, forall u3, forall u4, forall u5, (forall F', In F' LF_251 -> forall e1, forall e2, forall e3, forall e4, forall e5, less (snd (F' e1 e2 e3 e4 e5)) (snd (F u1 u2 u3 u4 u5)) -> fst (F' e1 e2 e3 e4 e5)) -> fst (F u1 u2 u3 u4 u5).
Proof.
intros F HF u1 u2 u3 u4 u5; case_In HF; intro Hind.

	(* GENERATE on [ 251 ] *)

rename u1 into _u1. rename u2 into _u2. rename u3 into _u3. rename u4 into d_u4. rename u5 into d_u5.
rename _u1 into u1. rename _u2 into u2. rename _u3 into u3.

revert Hind.

pattern u1, u2, u3, (f_251 u1 u2 u3). apply f_251_ind.

(* case [ 265 ] *)

intros _u1 _u2 _u3.  intro eq_1. intro. intro Heq2. rewrite <- Heq2. intro. intro Heq3. rewrite <- Heq3.  intro HFabs0.
assert (Hind := HFabs0 F_265). clear HFabs0.
assert (HFabs0 : fst (F_265 Nil 0 0 0 0)).
apply Hind. trivial_in 1. unfold snd. unfold F_265. unfold F_251. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_251. unfold F_265.
auto.

intros _u1 _u2 _u3. intro u8. intro u9. intro u4.  intro eq_1. intro. intro Heq2. rewrite <- Heq2. intro. intro Heq3. rewrite <- Heq3.  intro HFabs0.
case_eq (le (progAt (prog u4 _u2 _u3) (plus (time (C u8 u9)) _u3)) (er (C u8 u9))); [intro H | intro H].

(* case [ 271 ] *)

assert (Hind := HFabs0 F_271). clear HFabs0.
assert (HFabs0 : fst (F_271 u4 _u2 _u3 u8 u9)).
apply Hind. trivial_in 2. unfold snd. unfold F_271. unfold F_251. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_251. unfold F_271. simpl in H. repeat(simpl; rewrite H). repeat(simpl in HFabs0; rewrite H in HFabs0). try (auto || (intro H0; contradict H0)).
auto.

(* case [ 277 ] *)

assert (Hind := HFabs0 F_277). clear HFabs0.
assert (HFabs0 : fst (F_277 u4 _u2 _u3 u8 u9)).
apply Hind. trivial_in 3. unfold snd. unfold F_277. unfold F_251. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_251. unfold F_277. simpl in H. repeat(simpl; rewrite H). repeat(simpl in HFabs0; rewrite H in HFabs0). try (auto || (intro H0; contradict H0)).
auto.

	(* TAUTOLOGY on [ 265 ] *)

unfold fst. unfold F_265.
auto.

	(* REWRITING on [ 271 ] *)

rename u1 into _u4. rename u2 into _u2. rename u3 into _u3. rename u4 into _u8. rename u5 into _u9.
rename _u4 into u4. rename _u2 into u2. rename _u3 into u3. rename _u8 into u8. rename _u9 into u9.
assert (Res := Hind F_280). clear Hind.
assert (HFabs1 : fst (F_280 u4 u2 u3 u8 u9)).
apply Res. trivial_in 4. unfold snd. unfold F_280. unfold F_271. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_271. unfold fst in HFabs1. unfold F_280 in HFabs1.  specialize true_203 with (u1 := (prog u4 u2 u3)) (u2 := (plus (time (C u8 u9)) u3)) (u3 := (er (C u8 u9))). intro L. try rewrite L.
  simpl. auto.

	(* REWRITING on [ 277 ] *)

rename u1 into _u4. rename u2 into _u2. rename u3 into _u3. rename u4 into _u8. rename u5 into _u9.
rename _u4 into u4. rename _u2 into u2. rename _u3 into u3. rename _u8 into u8. rename _u9 into u9.
assert (Res := Hind F_283). clear Hind.
assert (HFabs1 : fst (F_283 u4 u2 u3 u8 u9)).
apply Res. trivial_in 6. unfold snd. unfold F_283. unfold F_277. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_277. unfold fst in HFabs1. unfold F_283 in HFabs1.  specialize true_157 with (u1 := (prog u4 u2 u3)) (u2 := (plus (time (C u8 u9)) u2)) (u3 := (er (C u8 u9))). intro L. try rewrite L.
  simpl. auto.

	(* REWRITING on [ 280 ] *)

rename u1 into _u4. rename u2 into _u2. rename u3 into _u3. rename u4 into _u8. rename u5 into _u9.
rename _u4 into u4. rename _u2 into u2. rename _u3 into u3. rename _u8 into u8. rename _u9 into u9.
assert (Res := Hind F_286). clear Hind.
assert (HFabs1 : fst (F_286 u4 u2 u3 u8 u9)).
apply Res. trivial_in 5. unfold snd. unfold F_286. unfold F_280. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_280. unfold fst in HFabs1. unfold F_286 in HFabs1.
pattern (C u8 u9), u4. simpl (erl _). cbv beta.
 simpl. auto.

	(* TAUTOLOGY on [ 286 ] *)

unfold fst. unfold F_286.
auto.

	(* REWRITING on [ 283 ] *)

rename u1 into _u4. rename u2 into _u2. rename u3 into _u3. rename u4 into _u8. rename u5 into _u9.
rename _u4 into u4. rename _u2 into u2. rename _u3 into u3. rename _u8 into u8. rename _u9 into u9.
assert (Res := Hind F_289). clear Hind.
assert (HFabs1 : fst (F_289 u4 u2 u3 u8 u9)).
apply Res. trivial_in 7. unfold snd. unfold F_289. unfold F_283. rewrite_model. abstract solve_rpo_mul.
unfold fst. unfold F_283. unfold fst in HFabs1. unfold F_289 in HFabs1.
pattern (C u8 u9), u4. simpl (erl _). cbv beta.
 simpl. auto.

	(* TAUTOLOGY on [ 289 ] *)

unfold fst. unfold F_289.
auto.

Qed.

(* the set of all formula instances from the proof *)
Definition S_251 := fun f => exists F, In F LF_251 /\ exists e1, exists e2, exists e3, exists e4, exists e5, f = F e1 e2 e3 e4 e5.

Theorem all_true_251: forall F, In F LF_251 -> forall u1: PLAN, forall u2: nat, forall u3: nat, forall u4: nat, forall u5: nat, fst (F u1 u2  u3  u4  u5).
Proof.
let n := constr:(5) in
let p := constr:(S(S(n))) in
intros;
let G := fresh "G" in
let x := fresh "x" in
apply wf_subset with (R:=@snd_rpo_mul P Prop max_size) (S:=S_251);
[(* 1 *) apply wf_snd_rpo_mul, prec_wf
|(* 2 *) idtac
|(* 3 *) eexists; split; [ eassumption | idtac]; do_nat n ltac:(eexists); reflexivity
];

intros x G;
do_nat p ltac:(elim G; intro; clear G; intro G);
rewrite G in * |- *; clear G; clear x;
intro G;
apply main_251;
 [assumption | idtac];
intros;
apply G;
 [ idtac | assumption ];
eexists; split;
 [idtac | do_nat n ltac:(eexists); reflexivity];
assumption.
Qed.

Theorem true_251: forall (u1: PLAN) (u2: nat) (u3: nat), (erl (prog u1 u2 u3)) = (erl u1).
Proof.
do 3 intro.
apply (all_true_251 F_251);
 (trivial_in 0) ||
 (repeat constructor).
Qed.


(* $Id: RefSeparating.v,v 1.15 2003/03/13 12:06:22 lcf Exp $ *)

Require Export IntegralLemmas.

Section Separating_Partition.

Variables a,b:IR.
Hypothesis Hab:(a[<=]b).
Local I:=(compact a b Hab).

Variable F:PartIR.
Hypothesis contF:(Continuous_I Hab F).
Hypothesis incF:(included (compact a b Hab) (Pred F)).

Hypothesis Hab':a[<]b.
Variable n:nat.
Variable P:(Partition Hab n).

Variable alpha:IR.
Hypothesis Halpha:Zero[<]alpha.

Variable csi:IR.
Hypothesis Hcsi:Zero[<]csi.

Local M:=(Norm_Funct contF).

Local pos_n : (lt O n).
Apply partition_less_imp_gt_zero with a b Hab; Assumption.
Qed.

Lemma SPap_n : ~n=O.
Intro.
Apply (lt_O_neq n).
Exact pos_n.
Auto.
Qed.

Local delta:=(Min csi alpha[/]?[//](mult_resp_ap_zero ??? (nring_ap_zero ?? SPap_n) (max_one_ap_zero M))).

Local pos_delta : Zero[<]delta.
Unfold delta; Apply less_Min.
Assumption.
Apply div_resp_pos.
Apply mult_resp_pos.
Step (!nring IR O); Apply nring_less; Apply pos_n.
Apply pos_max_one.
Assumption.
Qed.

Local delta_csi : delta[<=]csi.
Unfold delta; Apply Min_leEq_lft.
Qed.

Hypothesis Hab'' : delta[/]TwoNZ[<]b[-]a.

Lemma sep__part_lemma : (i:nat)(Hi:(le i n)){j:nat & {Hj:(Cle j n) &
  ((delta[/]FourNZ[<]((Pts P j (Cle_to ?? Hj))[-](Pts P i Hi)))*
    (j':nat)(Hj':(le j' n))(lt j' j)->((Pts P j' Hj')[-](Pts P i Hi)[<]delta[/]TwoNZ))}}+
  (((Pts P n (le_n n))[-](Pts P i Hi))[<]delta[/]TwoNZ).
Intros.
Elim (str_finite_or_elim ? [j:nat][Hj:(le j n)]delta[/]FourNZ[<]((Pts P j Hj)[-](Pts P i Hi))
  [j:nat][Hj:(le j n)]((Pts P j Hj))[-](Pts P i Hi)[<]delta[/]TwoNZ); Intros.
Left.
Elim a0; Intros j a'.
Elim a'; Intros Hj Hj'.
Elim Hj'; Clear a0 a' Hj'; Intros Hj' H0.
Exists j; Exists Hj.
Split; Assumption.
Right; Auto.
Red; Intros.
EApply less_wdr.
Apply H1.
Apply cg_minus_wd; Apply prf1; Auto.
Red; Intros.
EApply less_wdl.
Apply H1.
Apply cg_minus_wd; Apply prf1; Auto.
Apply cotrans_less_unfolded.
Apply shift_div_less.
Apply pos_four.
RStepr delta[+]delta.
Step Zero[+]delta.
Apply plus_resp_less_leEq.
Apply pos_delta.
Apply leEq_reflexive.
Qed.

Definition sep__part_h:nat->nat.
Intro i; Induction i.
Apply O.
Elim (le_lt_dec Hreci n); Intro.
Elim (sep__part_lemma Hreci a0); Intro.
Apply (ProjS1 a1).
Apply n.
Apply n.
Defined.

Lemma sep__part_h_bnd : (i:nat)(le (sep__part_h i) n).
Intro.
Induction i.
Apply le_O_n.
Simpl.
Elim (le_lt_dec (sep__part_h i) n); Intro; Simpl.
Elim (sep__part_lemma (sep__part_h i) a0); Intro; Simpl.
LetTac j:=(ProjS1 a1); Fold j.
Elim (ProjS2 a1); Intros Hj Hj'; Fold j in Hj Hj'.
Apply Cle_to; Assumption.
Apply le_n.
Apply le_n.
Qed.

Lemma sep__part_h_mon_1 : (i:nat)(le (sep__part_h i) (sep__part_h (S i))).
Intros; Simpl.
Elim (le_lt_dec (sep__part_h i) n); Intro; Simpl.
Elim (sep__part_lemma (sep__part_h i) a0); Intro; Simpl.
LetTac j:=(ProjS1 a1); Fold j.
Elim (ProjS2 a1); Intros Hj Hj'; Fold j in Hj Hj'.
Elim Hj'; Clear Hj'; Intros Hj0 Hj1.
Cut (lt (sep__part_h i) j); Intros.
Apply lt_le_weak; Assumption.
Apply (Partition_Points_mon ???? P) with a0 (Cle_to ?? Hj).
Apply less_transitive_unfolded with (Pts P (sep__part_h i) a0)[+]delta[/]FourNZ.
Apply shift_less_plus'; Step (Zero::IR).
Apply pos_div_four; Exact pos_delta.
Apply shift_plus_less'; Assumption.
Assumption.
Apply sep__part_h_bnd.
Qed.

Lemma sep__part_h_mon_2 : (i:nat)(lt (sep__part_h i) n)->(lt (sep__part_h i) (sep__part_h (S i))).
Intros; Simpl.
Elim (le_lt_dec (sep__part_h i) n); Intro; Simpl.
Elim (sep__part_lemma (sep__part_h i) a0); Intro; Simpl.
LetTac j:=(ProjS1 a1); Fold j.
Elim (ProjS2 a1); Intros Hj Hj'; Fold j in Hj Hj'.
Elim Hj'; Clear Hj'; Intros Hj0 Hj1.
Apply (Partition_Points_mon ???? P) with a0 (Cle_to ?? Hj).
Apply less_transitive_unfolded with (Pts P (sep__part_h i) a0)[+]delta[/]FourNZ.
Apply shift_less_plus'; Step (Zero::IR).
Apply pos_div_four; Exact pos_delta.
Apply shift_plus_less'; Assumption.
Assumption.
Assumption.
Qed.

Lemma sep__part_h_mon_3 : (i,j:nat)(lt (sep__part_h i) n)->(lt i j)->(lt (sep__part_h i) (sep__part_h j)).
Intros; Induction j.
ElimType False; Inversion H0.
Cut (le (sep__part_h j) (sep__part_h (S j))); Intros.
2: Apply sep__part_h_mon_1.
Elim (le_lt_eq_dec ?? H0); Intro.
Apply lt_le_trans with (sep__part_h j); Auto.
Apply Hrecj; Auto with arith.
Rewrite <- b0; Apply sep__part_h_mon_2; Auto.
Qed.

Lemma sep__part_app_n : {m:nat | (sep__part_h (S m))=n /\ ((i:nat)(le i m)->(lt (sep__part_h i) n))}.
Elim (weird_mon_covers ?? (sep__part_h_mon_2)); Intros m Hm Hm'.
LetTac m':=(pred m).
Exists m'.
Cut ~m=O; Intro.
Split.
Cut (S m')=m; [Intro | Unfold m'; Symmetry; Apply S_pred with O; Apply neq_O_lt; Auto].
Rewrite H0; Clear H0 m'.
Cut (le n (sep__part_h m)).
Cut (le (sep__part_h m) n); Intros.
Auto with arith.
Apply sep__part_h_bnd.
Assumption.
Intros; Apply Hm'.
Unfold m' in H0; Rewrite S_pred with m O; Auto with arith.
Apply neq_O_lt; Auto.
Apply SPap_n.
Rewrite H in Hm.
Simpl in Hm.
Apply le_antisym; Auto with arith.
Qed.

Lemma sep__part_h_lemma : (i:nat)(lt (sep__part_h (S i)) n)->(Hi:?)(Hi':?)
  (Pts P (sep__part_h i) Hi)[<](Pts P (sep__part_h (S i)) Hi').
Do 3 Intro; Simpl.
Elim (le_lt_dec (sep__part_h i) n); Intro; Simpl.
Elim (sep__part_lemma (sep__part_h i) a0); Intro; Simpl.
LetTac m':=(ProjS1 a1).
Change (Hi':(le m' n))(Pts P (sep__part_h i) Hi)[<](Pts P m' Hi'); Intros.
Elim (ProjS2 a1); Fold m'; Intros Hm' Hm''.
Inversion_clear Hm''.
Apply less_transitive_unfolded with (Pts P (sep__part_h i) Hi)[+]delta[/]FourNZ.
Apply shift_less_plus'; Step (Zero::IR); Apply pos_div_four; Exact pos_delta.
Apply shift_plus_less'; EApply less_wdr.
Apply H0.
Apply cg_minus_wd; Apply prf1; Auto.
Generalize H.
Simpl.
Elim (le_lt_dec (sep__part_h i) n); Intro; Simpl.
Elim (sep__part_lemma (sep__part_h i) a1); Intro; Simpl.
2: Intro; ElimType False; Apply (lt_n_n n); Auto.
2: Intro; ElimType False; Apply (lt_n_n n); Auto.
LetTac m':=(ProjS1 a2).
Change (lt m' n)->(Hi':(le n n))(Pts P (sep__part_h i) Hi)[<](Pts P n Hi'); Intros.
Elim (ProjS2 a2); Fold m'; Intros Hm' Hm''.
Inversion_clear Hm''.
Apply less_leEq_trans with (Pts P ? (Cle_to ?? Hm')).
Apply less_transitive_unfolded with (Pts P (sep__part_h i) Hi)[+]delta[/]FourNZ.
Apply shift_less_plus'; Step (Zero::IR); Apply pos_div_four; Exact pos_delta.
Apply shift_plus_less'; EApply less_wdr.
Apply H1.
Apply cg_minus_wd; Apply prf1; Auto.
Apply local_mon'_imp_mon'2_le with f:=[i:nat][Hi:?](Pts P i Hi).
Intros; Apply prf2.
Assumption.
ElimType False; Apply (le_not_lt ?? Hi b0).
Qed.

Lemma sep__part_h_lemma2 : (i:nat)(Hi:?)(Hi':?)(Pts P (pred (sep__part_h (S i))) Hi')[-](Pts P (sep__part_h i) Hi)[<=]delta[/]TwoNZ.
Do 2 Intro; Simpl.
Elim (le_lt_dec (sep__part_h i) n); Intro; Simpl.
Elim (sep__part_lemma (sep__part_h i) a0); Intro; Simpl.
LetTac j:=(ProjS1 a1).
Elim (ProjS2 a1); Fold j; Intros Hj Hj'; Inversion_clear Hj'.
Change (Hi':?)(Pts P (pred j) Hi')[-](Pts P ? Hi)[<=]delta[/]TwoNZ.
Intros; Apply less_leEq.
Apply less_wdl with (Pts P (pred j) Hi')[-](Pts P ? a0); Intros.
2: Apply cg_minus_wd; Apply prf1; Auto.
Apply H0.
Apply lt_pred_n_n.
Apply le_lt_trans with (sep__part_h i).
Apply le_O_n.
Apply Partition_Points_mon with P:=P Hi:=a0 Hj:=(Cle_to ?? Hj).
Apply less_transitive_unfolded with (Pts P (sep__part_h i) a0)[+]delta[/]FourNZ.
Apply shift_less_plus'; Step (Zero::IR); Apply pos_div_four; Exact pos_delta.
Apply shift_plus_less'; Assumption.
Intros; EApply leEq_transitive.
2: Apply less_leEq; Apply b0.
Unfold cg_minus; Apply plus_resp_leEq_both.
Apply Partition_mon; Assumption.
Apply inv_resp_leEq; Apply eq_imp_leEq; Apply prf1; Auto.
ElimType False; Exact (le_not_lt ?? (sep__part_h_bnd ?) b0).
Qed.

Lemma sep__part_h_lemma3 : (i,k:nat)(Hk:?)(Hk':?)(le (sep__part_h i) k)->(lt k (pred (sep__part_h (S i))))->
  (Pts P (S k) Hk')[-](Pts P k Hk)[<=]delta[/]TwoNZ.
Intros.
Cut (le (sep__part_h i) n).
Cut (le (pred (sep__part_h (S i))) n); Intros.
EApply leEq_transitive.
2: Apply sep__part_h_lemma2 with Hi:=H2 Hi':=H1.
Unfold cg_minus; Apply plus_resp_leEq_both.
Apply Partition_mon; Assumption.
Apply inv_resp_leEq; Apply Partition_mon; Assumption.
Apply le_trans with (sep__part_h (S i)).
Auto with arith.
Apply sep__part_h_bnd.
Apply sep__part_h_bnd.
Qed.

Local delta2_delta4 : (m:nat)
  (delta[/]FourNZ[<](Pts P ? (sep__part_h_bnd (S m)))[-](Pts P ? (sep__part_h_bnd m)))+
  ((Pts P ? (sep__part_h_bnd (S m)))[-](Pts P ? (sep__part_h_bnd m))[<]delta[/]TwoNZ).
Intro; Apply cotrans_less_unfolded.
RStep (delta[/]TwoNZ)[/]TwoNZ.
Apply pos_div_two'; Apply pos_div_two; Exact pos_delta.
Qed.

Local m1 := (proj1_sig ?? (sep__part_app_n)).

Local m:nat.
Elim (delta2_delta4 m1); Intro.
Apply (S m1).
Apply m1.
Defined.

Definition sep__part_length := m.

Local m_m1 : {m=m1}+{m=(S m1)}.
Unfold m; Clear m.
Elim (delta2_delta4 m1); Intro; Simpl.
Right; Auto.
Left; Auto.
Qed.

Local pos_m : (lt O m).
Unfold m.
Elim (delta2_delta4 m1); Intro; Simpl.
Auto with arith.
Elim (proj2_sig ?? sep__part_app_n); Fold m1; Intros.
Cut ~O=m1; Intro.
Auto with arith.
ElimType False.
Apply less_irreflexive_unfolded with x:=delta[/]TwoNZ.
Apply less_transitive_unfolded with b[-]a.
Assumption.
EApply less_wdl.
Apply b0.
Apply cg_minus_wd.
EApply eq_transitive_unfolded.
2: Apply finish with p:=P H:=(le_n n).
Apply prf1.
Auto.
EApply eq_transitive_unfolded.
2: Apply start with p:=P H:=(le_O_n n).
Apply prf1.
Rewrite <- H1.
Simpl; Auto.
Qed.

Definition sep__part_fun : (i:nat)(le i m)->nat.
Intros i Hi.
Elim (le_lt_eq_dec ?? Hi); Intro.
Apply (sep__part_h i).
Apply n.
Defined.

Lemma sep__part_fun_bnd : (i:nat)(H:(le i m))(le (sep__part_fun i H) n).
Intros.
Unfold sep__part_fun.
Elim (le_lt_eq_dec ?? H); Intro; Simpl.
Apply sep__part_h_bnd.
Apply le_n.
Qed.

Lemma sep__part_fun_0 : (H:(le O m))(sep__part_fun O H)=O.
Intros.
Unfold sep__part_fun.
Elim (le_lt_eq_dec ?? H); Intro; Simpl.
Reflexivity.
ElimType False.
Generalize b0.
Apply lt_O_neq; Apply pos_m.
Qed.

Lemma sep__part_fun_i : (i:nat)(H:(le i m))(lt i m)->(sep__part_fun i H)=(sep__part_h i).
Intros.
Unfold sep__part_fun.
Elim (le_lt_eq_dec ?? H); Intro; Simpl.
Reflexivity.
Rewrite b0 in H0; Elim (lt_n_n ? H0).
Qed.

Lemma sep__part_fun_m : (H:(le m m))(sep__part_fun m H)=n.
Intros.
Unfold sep__part_fun.
Elim (le_lt_eq_dec ?? H); Intro; Simpl.
Elim (lt_n_n ? a0).
Reflexivity.
Qed.

Lemma sep__part_fun_i' : (i:nat)(H:(le i m))(le (sep__part_h i) (sep__part_fun i H)).
Intros.
Unfold sep__part_fun.
Elim (le_lt_eq_dec ?? H); Intro; Simpl.
Apply le_n.
Apply sep__part_h_bnd.
Qed.

Lemma sep__part_fun_bnd' : (i:nat)(H:(le i m))(lt i m)->(lt (sep__part_fun i H) n).
Intros.
Unfold sep__part_fun.
Elim (le_lt_eq_dec ?? H); Intro; Simpl.
Elim (proj2_sig ?? sep__part_app_n).
Intros.
Apply H2.
Generalize a0; Clear a0.
Unfold m; Elim (delta2_delta4 m1); Intro; Simpl.
Auto with arith.
Auto with arith.
Rewrite b0 in H0; Elim (lt_n_n ? H0).
Qed.

Lemma sep__part_fun_wd : (i,j:nat)(Hi:?)(Hj:?)i=j->(sep__part_fun i Hi)=(sep__part_fun j Hj).
ClearBody m; Intros.
Unfold sep__part_fun.
Elim (le_lt_eq_dec ?? Hi); Elim (le_lt_eq_dec ?? Hj); Intros; Simpl.
Rewrite H; Auto.
Rewrite H in a0; Rewrite b0 in a0; Elim (lt_n_n ? a0).
Rewrite <- H in a0; Rewrite b0 in a0; Elim (lt_n_n ? a0).
Auto.
Qed.

Lemma sep__part_fun_mon : (i,j:nat)(Hi:?)(Hj:?)(lt i j)->(lt (sep__part_fun i Hi) (sep__part_fun j Hj)).
ClearBody m; Intros.
Apply less_nring with (IR::COrdField).
Apply local_mon_imp_mon_le with f:=[i:nat][Hi:(le i m)](!nring IR (sep__part_fun i Hi)).
Clear H Hj Hi j i; Intros; Apply nring_less.
2: Assumption.
Elim (le_lt_eq_dec ?? H'); Intro.
Rewrite sep__part_fun_i with i:=(S i).
2: Assumption.
Simpl; Elim (le_lt_dec (sep__part_h i) n); Intro; Simpl.
Elim (sep__part_lemma (sep__part_h i) a1); Intro; Simpl.
Elim (ProjS2 a2); LetTac j:=(ProjS1 a2).
Intros Hj Hj'.
Inversion_clear Hj'.
Rewrite sep__part_fun_i.
2: Auto with arith.
Apply (Partition_Points_mon ???? P) with a1 (Cle_to ?? Hj).
Apply less_transitive_unfolded with (Pts P ? a1)[+](delta[/]FourNZ).
Apply shift_less_plus'; Step (Zero::IR); Apply pos_div_four; Exact pos_delta.
Apply shift_plus_less'; Apply H0.
Apply sep__part_fun_bnd'; Auto with arith.
Apply sep__part_fun_bnd'; Auto with arith.
Generalize H'; Rewrite b0.
Intro; Rewrite sep__part_fun_m.
Apply sep__part_fun_bnd'.
Auto with arith.
Qed.

Definition sep__part : (Partition Hab sep__part_length).
Apply Build_Partition with [i:nat][Hi:(le i m)](Pts P ? (sep__part_fun_bnd i Hi)).
Intros; Apply prf1.
Apply sep__part_fun_wd; Auto.
Intros.
Apply local_mon'_imp_mon'2_le with f:=[i:nat][Hi:(le i n)](Pts P i Hi).
Intros; Apply prf2.
Apply sep__part_fun_mon; Auto.
Intro.
Apply eq_transitive_unfolded with (Pts P O (le_O_n ?)).
Apply prf1.
Apply sep__part_fun_0.
Apply start.
Intro; EApply eq_transitive_unfolded.
2: Apply finish with p:=P H:=(le_n n).
Apply prf1.
Apply sep__part_fun_m.
Defined.

Lemma sep__part_fun_mon_pts : (i:nat)(Hi:?)(Hi':?)(Hi0:?)(Hi'0:?)(Pts P (sep__part_fun i Hi) Hi0)[<](Pts P (sep__part_fun (S i) Hi') Hi'0).
Do 3 Intro.
Rewrite sep__part_fun_i.
2: Auto with arith.
Elim (le_lt_eq_dec ?? Hi'); Intro.
Rewrite sep__part_fun_i with i:=(S i).
2: Assumption.
Intros.
Apply sep__part_h_lemma.
Rewrite <- sep__part_fun_i with H:=Hi'.
Apply sep__part_fun_bnd'; Assumption.
Assumption.
Generalize Hi'; Clear Hi'; Rewrite b0.
Intro; Rewrite sep__part_fun_m.
Intros.
Cut m=m.
2: Auto.
Unfold 2 m; Elim (delta2_delta4 m1); Intro; Simpl; Intro.
Cut i=m1; [Clear b0; Intro | Rewrite <- b0 in H; Auto with arith].
Generalize Hi0; Clear Hi0; Rewrite H0.
Intro.
Elim (proj2_sig ?? (sep__part_app_n)); Fold m1; Intros.
Apply less_transitive_unfolded with (Pts P (sep__part_h m1) Hi0)[+]delta[/]FourNZ.
Apply shift_less_plus'; Step (Zero::IR); Apply pos_div_four; Apply pos_delta.
Apply shift_plus_less'; EApply less_wdr.
Apply a0.
Apply cg_minus_wd; Apply prf1.
Auto.
Auto.
Elim (proj2_sig ?? (sep__part_app_n)); Fold m1; Intros.
Generalize Hi'0; Clear Hi'0.
Cut (S i)=m1; [Intro | Transitivity m; Auto].
Pattern 1 5 n; Rewrite <- H0.
Rewrite <- H2.
Intro.
Apply less_leEq_trans with (Pts P ? (sep__part_h_bnd (S i))).
2: Apply local_mon'_imp_mon'_le with f:=[i:nat][Hi:(le i n)](Pts P i Hi).
2: Intros; Apply prf2.
2: Red; Intros; Apply prf1; Assumption.
2: Apply sep__part_h_mon_1.
Apply sep__part_h_lemma.
Apply H1.
Rewrite H2; Apply le_n.
Qed.

Lemma sep__part_mon : (i:nat)(Hi:?)(Hi':?)(Pts sep__part i Hi)[<](Pts sep__part (S i) Hi').
Intros.
Unfold sep__part; Simpl.
Apply sep__part_fun_mon_pts.
Qed.

Lemma sep__part_mon_Mesh : (Mesh sep__part)[<=](Mesh P)[+]csi.
Unfold 1 Mesh.
Apply maxlist_leEq.
Apply length_Part_Mesh_List.
Apply pos_m.
Intros.
Elim (Part_Mesh_List_lemma ?????? H).
Intros i Hi.
Elim Hi; Clear Hi; Intros Hi Hi'.
Elim Hi'; Clear Hi'; Intros Hi' Hx.
EApply leEq_wdl.
2: Apply eq_symmetric_unfolded; Apply Hx.
Clear Hx H x.
Simpl.
Cut (Ha:?)(Hb:?)(Pts P (sep__part_fun (S i) (Cle_to ?? Hi')) Ha)[-](Pts P (sep__part_fun i (Cle_to ?? Hi)) Hb)[<=](Mesh P)[+]csi.
Intro.
Apply H.
Cut (lt i m); [Intro | Red; Apply Cle_to; Assumption].
Rewrite sep__part_fun_i with i:=i.
2: Assumption.
Elim (le_lt_eq_dec ?? H); Intro.
Rewrite sep__part_fun_i.
2: Assumption.
Intros.
Cut (le (pred (sep__part_h (S i))) n); [Intro | EApply le_trans; [Apply le_pred_n | Auto]].
RStep ((Pts P ? Ha)[-](Pts P ? H0))[+]((Pts P ? H0)[-](Pts P ? Hb)).
Apply plus_resp_leEq_both.
Generalize Ha; Pattern 1 2 (sep__part_h (S i)); Replace (sep__part_h (S i)) with (S (pred (sep__part_h (S i)))); Intros.
Apply Mesh_lemma.
Symmetry; Apply S_pred with (sep__part_h i); Apply sep__part_h_mon_2.
Rewrite <- sep__part_fun_i with H:=(lt_le_weak ?? H).
Apply sep__part_fun_bnd'; Assumption.
Assumption.
EApply leEq_transitive.
Apply sep__part_h_lemma2.
Apply less_leEq; Apply less_leEq_trans with delta.
Apply pos_div_two'; Exact pos_delta.
Apply delta_csi.
Generalize Hi'; Clear Hi'; Rewrite b0; Intro.
Rewrite sep__part_fun_m.
Cut m=m; [Unfold 2 m | Auto].
Elim delta2_delta4; Intro; Simpl; Intro.
Intros.
Cut (sep__part_h (S m1))=n.
Intro; Generalize Ha Hb; Pattern 1 5 n.
Rewrite <- H1.
Cut i=m1; [Intro | Rewrite <- b0 in H0; Auto with arith].
Rewrite H2.
Intros.
Cut (le (pred (sep__part_h (S m1))) n); [Intro | EApply le_trans; [Apply le_pred_n | Auto]].
RStep ((Pts P ? Ha0)[-](Pts P ? H3))[+]((Pts P ? H3)[-](Pts P ? Hb0)).
Apply plus_resp_leEq_both.
Generalize Ha0; Pattern 1 2 (sep__part_h (S m1)); Replace (sep__part_h (S m1)) with (S (pred (sep__part_h (S m1)))); Intros.
Apply Mesh_lemma.
Symmetry; Apply S_pred with (sep__part_h m1); Apply sep__part_h_mon_2.
Cut (le m1 m).
2: Rewrite H0; Apply le_n_Sn.
Intro.
Rewrite <- sep__part_fun_i with H:=H4.
Apply sep__part_fun_bnd'.
Rewrite H0; Apply lt_n_Sn.
Rewrite H0; Apply lt_n_Sn.
EApply leEq_transitive.
Apply sep__part_h_lemma2.
Apply less_leEq; Apply less_leEq_trans with delta.
Apply pos_div_two'; Exact pos_delta.
Apply delta_csi.
Elim (proj2_sig ?? sep__part_app_n); Fold m1; Intros.
Auto.
Cut (sep__part_h (S m1))=n.
Intro; Pattern 1 5 n.
Rewrite <- H1.
Intros.
Cut (le (sep__part_h m1) n); [Intro | Apply sep__part_h_bnd].
RStep ((Pts P ? Ha)[-](Pts P ? H2))[+]((Pts P ? H2)[-](Pts P ? Hb)).
Apply leEq_transitive with (delta[/]TwoNZ)[+]((Mesh P)[+]delta[/]TwoNZ).
Apply plus_resp_leEq_both.
Apply less_leEq; EApply less_wdl.
Apply b1.
Apply cg_minus_wd; Apply prf1; Auto.
Generalize H2; Clear H2; Rewrite <- H0; Rewrite <- b0.
Simpl.
Elim (le_lt_dec (sep__part_h i) n); Intro; Simpl.
Elim (sep__part_lemma (sep__part_h i) a0); Intro; Simpl.
LetTac j:=(ProjS1 a1).
Change (H0:?)(Pts P j H0)[-](Pts P (sep__part_h i) Hb)[<=](Mesh P)[+]delta[/]TwoNZ.
Elim (ProjS2 a1); Fold j; Intros Hj Hj'.
Inversion_clear Hj'.
Intros.
Cut (le (pred j) n); [Intro | Apply le_trans with j; Auto with arith].
RStep ((Pts P j H4)[-](Pts P (pred j) H5))[+]((Pts P (pred j) H5)[-](Pts P (sep__part_h i) Hb)).
Cut (lt O j); Intros.
Apply plus_resp_leEq_both.
Cut j=(S (pred j)); [Intro | Apply S_pred with O; Auto].
Generalize H4; Pattern 1 2 j; Rewrite H7; Intro.
Apply Mesh_lemma.
Apply less_leEq.
Apply less_wdl with (Pts P (pred j) H5)[-](Pts P ? a0).
2: Apply cg_minus_wd; Apply prf1; Auto.
Apply H3.
Auto with arith.
Apply le_lt_trans with (sep__part_h i); Auto with arith.
Apply Partition_Points_mon with P:=P Hi:=a0 Hj:=(Cle_to ?? Hj).
Apply less_transitive_unfolded with (Pts P (sep__part_h i) a0)[+]delta[/]FourNZ.
Apply shift_less_plus'; Step (Zero::IR); Apply pos_div_four; Exact (pos_delta).
Apply shift_plus_less'; Assumption.
Intros.
Apply less_leEq; Apply less_leEq_trans with delta[/]TwoNZ.
EApply less_wdl.
Apply b2.
Apply cg_minus_wd; Apply prf1; Auto.
Step Zero[+]delta[/]TwoNZ; Apply plus_resp_leEq; Apply Mesh_nonneg.
ElimType False.
Exact (le_not_lt ?? (sep__part_h_bnd ?) b2).
RStep (Mesh P)[+]delta.
Apply plus_resp_leEq_lft; Apply delta_csi.
Elim (proj2_sig ?? sep__part_app_n); Fold m1; Intros.
Auto.
Qed.

Variable g:(i:nat)(lt i n)->IR.
Hypothesis gP : (Points_in_Partition P g).
Hypothesis gP' : (nat_less_n_fun ?? g).

Definition sep__part_pts [i:nat][Hi:(lt i sep__part_length)] : IR.
Intros.
Cut (lt (pred (sep__part_h (S i))) n); Intros.
Apply (g ? H).
Cut (lt (sep__part_h i) (sep__part_h (S i))).
2: Apply sep__part_h_mon_3.
Intro.
Red.
Replace (S (pred (sep__part_h (S i)))) with (sep__part_h (S i)); Intros.
Apply sep__part_h_bnd.
Apply S_pred with (sep__part_h i); Assumption.
Rewrite <- sep__part_fun_i with H:=(lt_le_weak ?? Hi).
Apply sep__part_fun_bnd'; Assumption.
Assumption.
Apply lt_n_Sn.
Defined.

Lemma sep__part_pts_lemma : (i:nat)(Hi:?)(Hi':?)(sep__part_pts i Hi)[=](g (pred (sep__part_h (S i))) Hi').
Intros; Unfold sep__part_pts.
Apply gP'; Auto.
Qed.

Lemma sep__part_pts_in_Partition : (Points_in_Partition sep__part sep__part_pts).
Red; Intros i Hi.
LetTac H:=(sep__part_h_mon_3 ?? (eq_ind nat (sep__part_fun i (lt_le_weak ?? Hi)) [n0:nat](lt n0 n) (sep__part_fun_bnd' i (lt_le_weak ?? Hi) Hi)
  (sep__part_h i) (sep__part_fun_i i (lt_le_weak ?? Hi) Hi)) (lt_n_Sn i)).
LetTac H0:=(S_pred (sep__part_h (S i)) (sep__part_h i) H).
LetTac H':=(eq_ind nat (sep__part_h (S i)) [j:nat](le j n) (sep__part_h_bnd (S i)) (S (pred (sep__part_h (S i)))) H0).
Elim (gP ? H'); Intros.
Simpl; Unfold sep__part_pts.
Split.
EApply leEq_transitive.
2: Apply a0.
Apply Partition_mon; Apply le_2.
Rewrite sep__part_fun_i; Assumption.
EApply leEq_transitive.
Apply b0.
Apply Partition_mon.
Rewrite <- H0.
Apply sep__part_fun_i'.
Qed.

Local Hsep_S : (i,j:nat)(Hi:(le (S i) m))(le j (pred (sep__part_fun (S i) Hi)))->(le (S j) n).
Intros.
Apply le_trans with (sep__part_fun (S i) Hi).
2: Apply sep__part_fun_bnd.
Rewrite (S_pred (sep__part_fun (S i) Hi) (sep__part_fun i (lt_le_weak ?? Hi))).
Auto with arith.
Apply sep__part_fun_mon; Apply lt_n_Sn.
Qed.

Local Hsep : (i,j:nat)(Hi:(le (S i) m))(le j (pred (sep__part_fun (S i) Hi)))->(le j n).
Intros.
Apply le_trans with (sep__part_fun (S i) Hi).
2: Apply sep__part_fun_bnd.
Rewrite (S_pred (sep__part_fun (S i) Hi) (sep__part_fun i (lt_le_weak ?? Hi))).
Apply le_S; Assumption.
Apply sep__part_fun_mon; Apply lt_n_Sn.
Qed.

Local h : nat->IR.
Intro i.
Elim (le_lt_dec i n); Intro.
Apply (Pts P i a0).
Apply (Zero::IR).
Defined.

Syntactic Definition just1:=(incF ? (Pts_part_lemma ?????? gP ??)).
Syntactic Definition just2:=(incF ? (Pts_part_lemma ?????? sep__part_pts_in_Partition ??)).

Local sep__part_sum1 : (i:nat)(Hi:(lt i m))
  (Sum2 [j:nat][Hj:(le (sep__part_fun i (lt_le_weak ?? Hi)) j)][Hj':(le j (pred (sep__part_fun (S i) Hi)))]
     (Pts P ? (Hsep_S ??? Hj'))[-](Pts P ? (Hsep ??? Hj')))[=](Pts sep__part ? Hi)[-](Pts sep__part ? (lt_le_weak ?? Hi)).
Intros; Simpl.
Unfold Sum2.
Cut (sep__part_fun (S i) Hi)=(S (pred (sep__part_fun (S i) Hi))).
2: Apply S_pred with (sep__part_fun i (lt_le_weak ?? Hi)); Apply sep__part_fun_mon; Apply lt_n_Sn.
Intro.
Cut (le (S (pred (sep__part_fun (S i) Hi))) n).
2: Rewrite <- H; Apply sep__part_fun_bnd.
Intro.
Apply eq_transitive_unfolded with (Pts P ? H0)[-](Pts P ? (sep__part_fun_bnd i (lt_le_weak ?? Hi))).
2: Apply cg_minus_wd; Apply prf1; Auto.
EApply eq_transitive_unfolded.
Apply str_Mengolli_Sum_gen with f:=h.
Rewrite <- H; Apply lt_le_weak; Apply sep__part_fun_mon; Apply lt_n_Sn.
Intro j; Intros.
Do 2 Elim le_lt_dec; Intros; Simpl.
Unfold h.
Do 2 Elim le_lt_dec; Intros; Simpl.
Apply cg_minus_wd; Apply prf1; Auto.
ElimType False; Apply le_not_lt with j n.
Apply le_trans with (S j); Auto with arith.
Assumption.
ElimType False; Apply le_not_lt with (S j) n.
Exact (Hsep_S ?? Hi a1).
Assumption.
ElimType False; Apply le_not_lt with (S j) n.
Exact (Hsep_S ?? Hi a1).
Assumption.
ElimType False; Exact (le_not_lt ?? H1 b0).
ElimType False; Exact (le_not_lt ?? H2 b0).
ElimType False; Exact (le_not_lt ?? H1 b0).
Unfold h.
Apply cg_minus_wd.
Elim le_lt_dec; Simpl; Intros.
Apply prf1; Auto.
ElimType False; Exact (le_not_lt ?? H0 b0).
Elim le_lt_dec; Intro; Simpl.
Apply prf1; Auto.
ElimType False; Rewrite <- H in H0; Apply le_not_lt with (sep__part_fun i (lt_le_weak ?? Hi)) n.
Apply sep__part_fun_bnd.
Assumption.
Qed.

Local sep__part_Sum2 : (Partition_Sum gP incF)[=](Sumx [i:nat][Hi:(lt i m)]
  (Sum2 [j:nat][Hj:(le (sep__part_fun i (lt_le_weak ?? Hi)) j)][Hj':(le j (pred (sep__part_fun (S i) Hi)))]
    (Part F (g j (Hsep_S ??? Hj')) just1)[*]((Pts P ? (Hsep_S ??? Hj'))[-](Pts P ? (Hsep ??? Hj'))))).
Unfold Partition_Sum.
Apply eq_symmetric_unfolded.
Unfold Sum2.
Apply eq_transitive_unfolded with (Sumx [j:nat][Hj:(lt j n)]
  (part_tot_nat_fun ?? [i:nat][H:(lt i n)](Part F (g i H) just1)[*]((Pts P ? H)[-](Pts P ? (lt_le_weak ?? H))) j)).
Apply str_Sumx_Sum_Sum' with g:=[i:nat][Hi:(lt i m)][i0:nat]
         (sumbool_rec (le (sep__part_fun i (lt_le_weak i m Hi)) i0)
           (lt i0 (sep__part_fun i (lt_le_weak i m Hi)))
           [_:(sumbool (le (sep__part_fun i (lt_le_weak i m Hi)) i0)
                (lt i0 (sep__part_fun i (lt_le_weak i m Hi))))]IR
           [_:(le (sep__part_fun i (lt_le_weak i m Hi)) i0)]
            (sumbool_rec (le i0 (pred (sep__part_fun (S i) Hi)))
              (lt (pred (sep__part_fun (S i) Hi)) i0)
              [_:(sumbool (le i0 (pred (sep__part_fun (S i) Hi)))
                   (lt (pred (sep__part_fun (S i) Hi)) i0))]IR
              [H0:(le i0 (pred (sep__part_fun (S i) Hi)))]
               (F (g i0 (Hsep_S i i0 Hi H0))
                  (incF (g i0 (Hsep_S i i0 Hi H0))
                    (Pts_part_lemma a b Hab n P g gP i0
                      (Hsep_S i i0 Hi H0))))[*]
                 ((Pts P (S i0) (Hsep_S i i0 Hi H0))[-]
                    (Pts P i0 (Hsep i i0 Hi H0)))
              [_:(lt (pred (sep__part_fun (S i) Hi)) i0)]Zero
              (le_lt_dec i0 (pred (sep__part_fun (S i) Hi))))
           [_:(lt i0 (sep__part_fun i (lt_le_weak i m Hi)))]Zero
           (le_lt_dec (sep__part_fun i (lt_le_weak i m Hi)) i0))
  h:=(part_tot_nat_fun ?? [i:nat][H:(lt i n)](Part F (g i H) just1)[*]
       ((Pts P ? H)[-](Pts P ? (lt_le_weak ?? H)))).
Apply sep__part_fun_0.
Intros; Apply sep__part_fun_wd; Auto.
Intros; Apply sep__part_fun_mon; Auto.
Intros.
Elim le_lt_dec; Intro; Simpl.
Elim le_lt_dec; Intro; Simpl.
Unfold part_tot_nat_fun.
Elim (le_lt_dec n j); Intro; Simpl.
ElimType False.
Apply le_not_lt with n j.
Assumption.
Apply lt_le_trans with (sep__part_fun (S i) Hi'').
Assumption.
Apply sep__part_fun_bnd.
Apply mult_wd; Algebra.
Apply cg_minus_wd; Apply prf1; Auto.
ElimType False.
Apply le_not_lt with (sep__part_fun i Hi') j.
Assumption.
Cut (sep__part_fun i Hi')=(sep__part_fun i (lt_le_weak ?? Hi)); [Intro | Apply sep__part_fun_wd; Auto].
Rewrite H1; Assumption.
ElimType False.
Apply le_not_lt with (S j) (sep__part_fun (S i) Hi).
Cut (sep__part_fun (S i) Hi)=(sep__part_fun (S i) Hi''); [Intro | Apply sep__part_fun_wd; Auto].
Rewrite H1; Apply H0.
Rewrite (S_pred (sep__part_fun (S i) Hi) (sep__part_fun i (lt_le_weak ?? Hi))).
Auto with arith.
Apply sep__part_fun_mon; Apply lt_n_Sn.
Intros; Symmetry; Apply sep__part_fun_m.
Apply Sumx_wd; Intros.
Unfold part_tot_nat_fun.
Elim (le_lt_dec n i); Intro; Simpl.
ElimType False; Apply le_not_lt with n i; Auto.
Apply mult_wd; Algebra.
Apply cg_minus_wd; Apply prf1; Auto.
Qed.

Local sep__part_Sum3 : (AbsIR (Partition_Sum gP incF)[-]
  (Partition_Sum sep__part_pts_in_Partition incF))[=]
    (AbsIR (Sumx [i:nat][Hi:(lt i m)]
      (Sum2 [j:nat][Hj:(le (sep__part_fun i (lt_le_weak ?? Hi)) j)][Hj':(le j (pred (sep__part_fun (S i) Hi)))]
        ((Part F (g j (Hsep_S ??? Hj')) just1)[-](Part F (sep__part_pts i Hi) just2))[*]
        ((Pts P ? (Hsep_S ??? Hj'))[-](Pts P ? (Hsep ??? Hj')))))).
Apply AbsIR_wd.
Apply eq_transitive_unfolded with (Sumx [i:nat][Hi:(lt i m)]
    (Sum2 [j:nat][Hj:(le (sep__part_fun i (lt_le_weak ?? Hi)) j)][Hj':(le j (pred (sep__part_fun (S i) Hi)))]
      (Part F (g j (Hsep_S ??? Hj')) just1)[*]((Pts P ? (Hsep_S ??? Hj'))[-](Pts P ? (Hsep ??? Hj'))))[-]
    ((Part F (sep__part_pts i Hi) just2)[*]
    (Sum2 [j:nat][Hj:(le (sep__part_fun i (lt_le_weak ?? Hi)) j)][Hj':(le j (pred (sep__part_fun (S i) Hi)))]
        (Pts P ? (Hsep_S ??? Hj'))[-](Pts P ? (Hsep ??? Hj'))))).
EApply eq_transitive_unfolded.
2: Apply Sumx_minus_Sumx with
  f:=[i:nat][Hi:(lt i m)](Sum2 [j:nat][Hj:(le (sep__part_fun i (lt_le_weak ?? Hi)) j)][Hj':(le j (pred (sep__part_fun (S i) Hi)))]
      (Part F (g j (Hsep_S ??? Hj')) just1)[*]((Pts P ? (Hsep_S ??? Hj'))[-](Pts P ? (Hsep ??? Hj'))))
  g:=[i:nat][Hi:(lt i m)]((Part F (sep__part_pts i Hi) just2)[*]
      (Sum2 [j:nat][Hj:(le (sep__part_fun i (lt_le_weak ?? Hi)) j)][Hj':(le j (pred (sep__part_fun (S i) Hi)))]
        (Pts P ? (Hsep_S ??? Hj'))[-](Pts P ? (Hsep ??? Hj')))).
Apply cg_minus_wd.
Apply sep__part_Sum2.
Unfold Partition_Sum; Apply Sumx_wd; Intros.
Apply mult_wd_rht.
Apply eq_symmetric_unfolded; Apply sep__part_sum1.
Apply Sumx_wd; Intros i Hi.
Apply eq_transitive_unfolded with
    (Sum2 [j:nat][Hj:(le (sep__part_fun i (lt_le_weak ?? Hi)) j)][Hj':(le j (pred (sep__part_fun (S i) Hi)))]
      (Part F (g j (Hsep_S ??? Hj')) just1)[*]((Pts P ? (Hsep_S ??? Hj'))[-](Pts P ? (Hsep ??? Hj'))))[-]
      (Sum2 [j:nat][Hj:(le (sep__part_fun i (lt_le_weak ?? Hi)) j)][Hj':(le j (pred (sep__part_fun (S i) Hi)))]
    ((Part F (sep__part_pts i Hi) just2)[*]((Pts P ? (Hsep_S ??? Hj'))[-](Pts P ? (Hsep ??? Hj'))))).
Apply cg_minus_wd.
Algebra.
Apply eq_symmetric_unfolded; EApply eq_transitive_unfolded.
2: Apply Sum2_comm_scal'.
Algebra.
Rewrite <- (S_pred (sep__part_fun (S i) Hi) (sep__part_fun i (lt_le_weak ?? Hi)) (sep__part_fun_mon ???? (lt_n_Sn i))).
Apply lt_le_weak; Apply sep__part_fun_mon; Apply lt_n_Sn.
EApply eq_transitive_unfolded.
Apply Sum2_minus_Sum2.
Rewrite <- (S_pred (sep__part_fun (S i) Hi) (sep__part_fun i (lt_le_weak ?? Hi)) (sep__part_fun_mon ???? (lt_n_Sn i))).
Apply lt_le_weak; Apply sep__part_fun_mon; Apply lt_n_Sn.
Apply Sum2_wd; Intros.
Rewrite <- (S_pred (sep__part_fun (S i) Hi) (sep__part_fun i (lt_le_weak ?? Hi)) (sep__part_fun_mon ???? (lt_n_Sn i))).
Apply lt_le_weak; Apply sep__part_fun_mon; Apply lt_n_Sn.
Algebra.
Qed.

Local sep__part_Sum4 : (Sumx [i:nat][Hi:(lt i m)]
  (Sum2 [j:nat][Hj:(le (sep__part_fun i (lt_le_weak ?? Hi)) j)][Hj':(le j (pred (sep__part_fun (S i) Hi)))]
    (M[+]M)[*](delta[/]TwoNZ)))[<=]alpha.
Unfold Sum2.
Apply leEq_wdl with (Sumx [j:nat][_:(lt j n)](part_tot_nat_fun ?? [i:nat][_:(lt i n)](M[+]M)[*](delta[/]TwoNZ) j)).
2: Apply eq_symmetric_unfolded; Apply str_Sumx_Sum_Sum' with
  g:=[i:nat][Hi:(lt i m)][i0:nat]
              (sumbool_rec (le (sep__part_fun i (lt_le_weak i m Hi)) i0)
           (lt i0 (sep__part_fun i (lt_le_weak i m Hi)))
           [_:(sumbool (le (sep__part_fun i (lt_le_weak i m Hi)) i0)
                (lt i0 (sep__part_fun i (lt_le_weak i m Hi))))]IR
           [_:(le (sep__part_fun i (lt_le_weak i m Hi)) i0)]
            (sumbool_rec (le i0 (pred (sep__part_fun (S i) Hi)))
              (lt (pred (sep__part_fun (S i) Hi)) i0)
              [_:(sumbool (le i0 (pred (sep__part_fun (S i) Hi)))
                   (lt (pred (sep__part_fun (S i) Hi)) i0))]IR
              [_:(le i0 (pred (sep__part_fun (S i) Hi)))]
               (M[+]M)[*]delta[/]TwoNZ
              [_:(lt (pred (sep__part_fun (S i) Hi)) i0)]Zero
              (le_lt_dec i0 (pred (sep__part_fun (S i) Hi))))
           [_:(lt i0 (sep__part_fun i (lt_le_weak i m Hi)))]Zero
           (le_lt_dec (sep__part_fun i (lt_le_weak i m Hi)) i0))
  h:=(part_tot_nat_fun ?? [i:nat][_:(lt i n)](M[+]M)[*](delta[/]TwoNZ)).
Apply leEq_wdr with (Sumx [i:nat][_:(lt i n)](alpha[/]?[//](nring_ap_zero ?? SPap_n))).
2: RStepr (nring n)[*](alpha[/]?[//](nring_ap_zero ?? SPap_n)); Apply sumx_const.
Apply Sumx_resp_leEq; Intros.
Unfold part_tot_nat_fun.
Elim (le_lt_dec n i); Intro; Simpl.
ElimType False; Exact (le_not_lt ?? a0 H).
Unfold delta.
Apply leEq_transitive with (M[+]M)[*]((alpha[/]?[//](mult_resp_ap_zero ??? (nring_ap_zero ?? SPap_n) (max_one_ap_zero M)))[/]TwoNZ).
Apply mult_resp_leEq_lft.
Apply div_resp_leEq.
Apply pos_two.
Apply Min_leEq_rht.
Step (Zero::IR)[+]Zero; Apply plus_resp_leEq_both; Unfold M; Apply positive_norm.
RStep alpha[*](M[/]?[//](max_one_ap_zero M))[*](One[/]?[//](nring_ap_zero ?? SPap_n)).
RStepr alpha[*]One[*](One[/]?[//](nring_ap_zero ?? SPap_n)).
Apply mult_resp_leEq_rht.
Apply mult_resp_leEq_lft.
Apply shift_div_leEq.
Apply pos_max_one.
Stepr (Max M One); Apply lft_leEq_Max.
Apply less_leEq; Assumption.
Apply less_leEq; Apply recip_resp_pos.
Step (!nring IR O); Apply nring_less; Apply pos_n.
Apply sep__part_fun_0.
Exact sep__part_fun_wd.
Exact sep__part_fun_mon.
Unfold part_tot_nat_fun.
Intros; Elim (le_lt_dec (sep__part_fun i (lt_le_weak ?? Hi)) j); Intro; Simpl.
Elim (le_lt_dec j (pred (sep__part_fun (S i) Hi))); Intro; Simpl.
Elim (le_lt_dec n j); Intro; Simpl.
ElimType False; Apply (le_not_lt n j).
Assumption.
EApply lt_le_trans.
Apply H0.
Apply sep__part_fun_bnd.
Algebra.
ElimType False; Apply (le_not_lt ?? H0).
Rewrite (S_pred (sep__part_fun (S i) Hi'') (sep__part_fun i Hi')).
Cut (sep__part_fun (S i) Hi'')=(sep__part_fun (S i) Hi); [Intro | Apply sep__part_fun_wd; Auto].
Rewrite H1; Auto with arith.
Apply sep__part_fun_mon.
Apply lt_n_Sn.
ElimType False; Apply (le_not_lt ?? H).
Rewrite sep__part_fun_i.
2: Assumption.
Rewrite sep__part_fun_i in b0; Assumption.
Intros; Symmetry; Apply sep__part_fun_m.
Qed.

Local sep__part_aux : (i:nat)(lt (pred (sep__part_h (S i))) n).
Intros.
Red.
Rewrite <- S_pred with (sep__part_h (S i)) (sep__part_h O).
Apply sep__part_h_bnd.
Apply sep__part_h_mon_3.
Rewrite <- sep__part_fun_i with H:=(le_O_n m).
2: Apply pos_m.
2: Apply lt_O_Sn.
Rewrite <- sep__part_fun_m with H:=(le_n m).
Apply sep__part_fun_mon.
Apply pos_m.
Qed.

Lemma sep__part_Sum : (AbsIR (Partition_Sum gP incF)[-](Partition_Sum sep__part_pts_in_Partition incF))[<=]alpha.
EApply leEq_wdl.
2: Apply eq_symmetric_unfolded; Apply sep__part_Sum3.
EApply leEq_transitive.
2: Apply sep__part_Sum4.
EApply leEq_transitive.
Apply triangle_SumxIR.
Apply Sumx_resp_leEq; Intros.
EApply leEq_transitive.
Apply triangle_Sum2IR.
Rewrite <- (S_pred (sep__part_fun (S i) H) (sep__part_fun i (lt_le_weak ?? H)) (sep__part_fun_mon ???? (lt_n_Sn i))).
Apply lt_le_weak; Apply sep__part_fun_mon; Apply lt_n_Sn.
Apply Sum2_resp_leEq.
Rewrite <- (S_pred (sep__part_fun (S i) H) (sep__part_fun i (lt_le_weak ?? H)) (sep__part_fun_mon ???? (lt_n_Sn i))).
Apply lt_le_weak; Apply sep__part_fun_mon; Apply lt_n_Sn.
Intros k Hk Hk'.
Elim (le_lt_dec m (S i)); Intro.
Cut (S i)=m; [Intro | Clear Hk Hk'; Omega].
Generalize H0.
Unfold 1 m; Elim delta2_delta4; Intro; Simpl; Intro.
Cut (lt i m); [Intro | Assumption].
Apply leEq_wdl with (AbsIR ((Part F (g k (Hsep_S ?? H Hk')) just1)[-](Part F (g ? (sep__part_aux m1)) just1))[*]
  ((Pts P (S k) (Hsep_S ?? H Hk'))[-](Pts P k (Hsep ?? H Hk')))).
2: Apply AbsIR_wd; Apply mult_wd_lft.
2: Apply cg_minus_wd; [Algebra | Idtac].
2: Cut i=m1; [Intro | Auto].
2: Generalize H; Rewrite H3; Intro.
2: Unfold sep__part_pts; Simpl; Algebra.
Elim (le_lt_dec (pred (sep__part_h (S m1))) k); Intro.
Cut (pred (sep__part_h (S m1)))=k; Intros.
Apply leEq_wdl with (Zero::IR).
Step (Zero[+]Zero)[*](Zero::IR).
Apply mult_resp_leEq_both.
Apply eq_imp_leEq; Algebra.
Apply leEq_reflexive.
Apply plus_resp_leEq_both; Unfold M; Apply positive_norm.
Apply less_leEq; Stepr delta[/]TwoNZ; Apply pos_div_two; Exact pos_delta.
Apply eq_symmetric_unfolded; EApply eq_transitive_unfolded.
2: Apply AbsIRz_isz.
Apply AbsIR_wd.
RStepr ((Part F (g ? (sep__part_aux m1)) just1)[-](Part F (g ? (sep__part_aux m1)) just1))[*]
  ((Pts P (S k) (Hsep_S ?? H Hk'))[-](Pts P k (Hsep ?? H Hk'))).
Algebra.
Cut (H:?)(sep__part_fun (S i) H)=n.
Intro.
Cut (sep__part_h (S m1))=n; Intros.
Rewrite H4 in a2.
Rewrite H3 in Hk'.
Rewrite H4.
Apply le_antisym; Auto.
Elim (proj2_sig ?? (sep__part_app_n)); Fold m1; Intros.
Auto.
Rewrite H0; Exact sep__part_fun_m.
EApply leEq_wdl.
2: Apply eq_symmetric_unfolded; Apply AbsIR_resp_mult.
Apply mult_resp_leEq_both; Try Apply AbsIR_nonneg.
EApply leEq_transitive.
Apply triangle_IR_minus.
Apply plus_resp_leEq_both; Unfold M I; Apply norm_bnd_AbsIR; Apply Pts_part_lemma with n P; Apply gP.
EApply leEq_wdl.
2: Apply eq_symmetric_unfolded; Apply AbsIR_eq_x.
2: Apply shift_leEq_minus; Step (Pts P k (Hsep i k H Hk')); Apply prf2.
Apply sep__part_h_lemma3 with i.
Rewrite sep__part_fun_i in Hk; Assumption.
Rewrite H1; Assumption.
Apply leEq_wdl with (AbsIR ((Part F (g k (Hsep_S ?? H Hk')) just1)[-](Part F (g ? (sep__part_aux i)) just1))[*]
  ((Pts P (S k) (Hsep_S ?? H Hk'))[-](Pts P k (Hsep ?? H Hk')))).
2: Apply AbsIR_wd; Apply mult_wd.
2: Apply cg_minus_wd; Apply pfwdef; [Algebra | Unfold sep__part_pts; Apply gP']; Auto.
2: Apply cg_minus_wd; Apply prf1; Auto.
Elim (le_lt_dec (pred (sep__part_h m1)) k); Intro.
Elim (le_lt_eq_dec ?? a1); Intro.
EApply leEq_wdl.
2: Apply eq_symmetric_unfolded; Apply AbsIR_resp_mult.
Apply mult_resp_leEq_both; Try Apply AbsIR_nonneg.
EApply leEq_transitive.
Apply triangle_IR_minus.
Apply plus_resp_leEq_both; Unfold M I; Apply norm_bnd_AbsIR; Apply Pts_part_lemma with n P; Assumption.
EApply leEq_wdl.
2: Apply eq_symmetric_unfolded; Apply AbsIR_eq_x.
2: Apply shift_leEq_minus; Step (Pts P k (Hsep i k H Hk')); Apply prf2.
Apply less_leEq; EApply leEq_less_trans.
2: Apply b0.
Unfold cg_minus; Apply plus_resp_leEq_both.
Apply Partition_mon.
Rewrite (S_pred (sep__part_h (S m1)) (sep__part_h m1)).
Apply le_n_S.
Cut (H:?)(sep__part_h (S m1))=(sep__part_fun (S i) H); Intros.
Rewrite (H2 H); Assumption.
Generalize H2; Rewrite H0.
Intro; Rewrite sep__part_fun_m.
Elim (proj2_sig ?? (sep__part_app_n)); Fold m1; Auto.
Apply sep__part_h_mon_3.
Elim (proj2_sig ?? (sep__part_app_n)); Fold m1; Intros.
Apply H3; Apply le_n.
Apply lt_n_Sn.
Apply inv_resp_leEq; Apply Partition_mon.
EApply le_trans.
2: Apply a2.
Clear Hk Hk'; Omega.
Apply leEq_wdl with (Zero::IR).
Step (Zero[+]Zero)[*](Zero::IR).
Apply mult_resp_leEq_both.
Apply eq_imp_leEq; Algebra.
Apply leEq_reflexive.
Apply plus_resp_leEq_both; Unfold M; Apply positive_norm.
Apply less_leEq; Stepr delta[/]TwoNZ; Apply pos_div_two; Exact pos_delta.
Apply eq_symmetric_unfolded; EApply eq_transitive_unfolded.
2: Apply AbsIRz_isz.
Apply AbsIR_wd.
RStepr ((Part F (g ? (sep__part_aux i)) just1)[-](Part F (g ? (sep__part_aux i)) just1))[*]
  ((Pts P (S k) (Hsep_S ?? H Hk'))[-](Pts P k (Hsep ?? H Hk'))).
Apply mult_wd_lft.
Apply cg_minus_wd; Apply pfwdef; Apply gP'; Auto.
Rewrite H1; Auto.
EApply leEq_wdl.
2: Apply eq_symmetric_unfolded; Apply AbsIR_resp_mult.
Apply mult_resp_leEq_both; Try Apply AbsIR_nonneg.
EApply leEq_transitive.
Apply triangle_IR_minus.
Apply plus_resp_leEq_both; Unfold M I; Apply norm_bnd_AbsIR; Apply Pts_part_lemma with n P; Assumption.
EApply leEq_wdl.
2: Apply eq_symmetric_unfolded; Apply AbsIR_eq_x.
2: Apply shift_leEq_minus; Step (Pts P k (Hsep i k H Hk')); Apply prf2.
Apply sep__part_h_lemma3 with i.
Rewrite sep__part_fun_i in Hk; Assumption.
Rewrite H1; Assumption.
Elim (le_lt_eq_dec ?? Hk'); Intro.
EApply leEq_wdl.
2: Apply eq_symmetric_unfolded; Apply AbsIR_resp_mult.
Apply mult_resp_leEq_both; Try Apply AbsIR_nonneg.
EApply leEq_transitive.
Apply triangle_IR_minus.
Apply plus_resp_leEq_both; Unfold M I; Apply norm_bnd_AbsIR.
Apply Pts_part_lemma with n P; Assumption.
Apply Pts_part_lemma with sep__part_length sep__part; Apply sep__part_pts_in_Partition.
Cut (le (pred (sep__part_fun (S i) H)) n); Intros.
EApply leEq_wdl.
2: Apply eq_symmetric_unfolded; Apply AbsIR_eq_x.
2: Apply shift_leEq_minus; Step (Pts P k (Hsep i k H Hk')); Apply prf2.
Apply sep__part_h_lemma3 with i.
Rewrite sep__part_fun_i in Hk; Assumption.
Rewrite sep__part_fun_i in a0; Assumption.
Apply le_trans with (sep__part_fun (S i) H).
Auto with arith.
Apply sep__part_fun_bnd.
Apply leEq_wdl with (Zero::IR).
Step (Zero[+]Zero)[*](Zero::IR).
Apply mult_resp_leEq_both.
Apply eq_imp_leEq; Algebra.
Apply leEq_reflexive.
Apply plus_resp_leEq_both; Unfold M; Apply positive_norm.
Apply less_leEq; Stepr delta[/]TwoNZ; Apply pos_div_two; Exact pos_delta.
Apply eq_symmetric_unfolded; EApply eq_transitive_unfolded.
2: Apply AbsIRz_isz.
Apply AbsIR_wd.
RStepr ((Part F (g ? (sep__part_aux i)) just1)[-](Part F (g ? (sep__part_aux i)) just1))[*]
  ((Pts P (S k) (Hsep_S ?? H Hk'))[-](Pts P k (Hsep ?? H Hk'))).
Apply mult_wd_lft.
Apply cg_minus_wd; Apply pfwdef; Unfold sep__part_pts; Apply gP'; Auto.
Rewrite sep__part_fun_i in b1; Assumption.
Qed.

End Separating_Partition.