Section Fix_measure_rects.
Variable A: Set.
Variable R: A -> A -> Prop.
Variable Rwf: well_founded R.
Variable P: A -> Type.
Variable f: forall x: A, (forall y: { y: A | R y x }, P (proj1_sig y)) -> P x.
(* Let's call f's second parameter its "lowers" function, since it provides it access to results for inputs with a lower measure.  In preparation of lemma similar to F_sub_rect, but for Wf.Fix_measure_sub (which is what Program uses), we first need an extra hypothesis stating that the function body has the same result for different "lowers" functions (g and h below) as long as those produce the same results for lower inputs, regardless of the lt proofs. *)
Hypothesis equiv_lowers:
forall x0 (g h: forall x: {y: A | R y x0}, P (proj1_sig x)),
(forall x p p', g (exist (fun y: A => R y x0) x p) = h (exist _ x p')) ->
f g = f h.
(* From equiv_lowers, it follows that [Wf.Fix_measure_F_sub A m P f x] applications do not not depend on the Acc proofs. *)
(* Finally, Fix_measure_F_rect lets one prove a property of functions defined using Wf.Fix_measure_F by showing that property to be invariant over single application of the function body (f). *)

Lemma rect
(Q: forall x, P x -> Type)
(inv: forall
(x: A)
(H: forall (y: A), R y x -> Q y (Wf.Fix_sub A R Rwf P f y))
(a: Acc R x),
Q x (f (fun y: {y: A | R y x} => Wf.Fix_sub A R Rwf P f (proj1_sig y))))
: forall x, Q _ (Wf.Fix_sub A R Rwf P f x).