summaryrefslogtreecommitdiff
path: root/contrib/subtac/FixSub.v
blob: ded069bf1f9b771969d26be6587aab6f7b509de2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Require Import Wf.

Section Well_founded.
Variable A : Set.
Variable R : A -> A -> Prop.
Hypothesis Rwf : well_founded R.

Section FixPoint.

Variable P : A -> Set.

Variable F_sub : forall x:A, (forall y: { y : A | R y x }, P (proj1_sig y)) -> P x.
 
Fixpoint Fix_F_sub (x : A) (r : Acc R x) {struct r} : P x :=
   F_sub x (fun y: { y : A | R y x}  => Fix_F_sub (proj1_sig y) 
   (Acc_inv r (proj1_sig y) (proj2_sig y))).

Definition Fix_sub (x : A) := Fix_F_sub x (Rwf x).

End FixPoint.

End Well_founded.

Require Import Wf_nat.
Require Import Lt.

Section Well_founded_measure.
Variable A : Set.
Variable f : A -> nat.
Definition R := fun x y => f x < f y.

Section FixPoint.

Variable P : A -> Set.

Variable F_sub : forall x:A, (forall y: { y : A | f y < f x }, P (proj1_sig y)) -> P x.
 
Fixpoint Fix_measure_F_sub (x : A) (r : Acc lt (f x)) {struct r} : P x :=
   F_sub x (fun y: { y : A | f y < f x}  => Fix_measure_F_sub (proj1_sig y) 
   (Acc_inv r (f (proj1_sig y)) (proj2_sig y))).

Definition Fix_measure_sub (x : A) := Fix_measure_F_sub x (lt_wf (f x)).

End FixPoint.

End Well_founded_measure.