Module Mf(M:Sigf)<:Sigf
with Definition f:=M.f
with Definition f_1:=M.f_1.
Definition f:=M.f.
Definition f_1:=M.f_1.
Definition exd_f:=M.exd_f.
Definition exd_f_1:=M.exd_f_1.
Definition bij_f:=M.bij_f.
Definition bij_f_1:=M.bij_f_1.
Definition f_1_f:=M.f_1_f.
Definition f_f_1:=M.f_f_1.
(*======================================================== ITERATIONS IN ORBITS: WITH NOETHERIAN INDUCTION =======================================================*)
(* REMAINING DARTS DURING f ITERATION ON z STARTING FROM A set sx: *)
(*======================================================== EXISTENCY PROPERTIES OF ITERATED DARTS, upb IN ORBITS...: WITH NOETHERIAN IND. =======================================================*)
(* FOR THE FOLLOWING LEMMA: *)
Definition P1
(m:fmap)(z:dart)(s:set):Prop:=
let sr := Iter_rem_aux m z s in
let n := Iter_upb_aux m z s in
~ exds sr (Iter (f m) n z).
(* THE upb_ITERATED DART BY f DOES NOT REMAIN: *)
(* THE upb_ITERATED DART BY f DOES NOT REMAIN: *)
(* THE upb_ITERATED DART BY f IS IN m: *)
(* THE upb_ITERATED DART BY f IS IN THE COMPLEMENTARY: *)
(* NOT REMAINING EQUIVALENT TO BEING IN THE COMPLEMENTARY: *)
Definition R3
(m:fmap)(z t:dart)(s:set):Prop:=
~ exds s t ->
let sr := Iter_rem_aux m z s in
~ exds sr t.
Definition R2
(m:fmap)(z:dart)(s:set):Prop:=
let sr := Iter_rem_aux m z s in
~ exds sr (Iter (f m) (ndN m - card s)%nat z).
(* OK!! BUT omega IS LONG... *)
Definition R1
(m:fmap)(z:dart)(i:nat)(s:set):Prop:=
let sr := Iter_rem_aux m z s in
let n := Iter_upb_aux m z s in
(ndN m - card s <= i <= n)%nat ->
~ exds sr (Iter (f m) i z).
(* VERY IMPORTANT: COROLLARIES: *)
(*======================================================== card PROPERTIES OF ORBITS: WITH NOETHERIAN INDUCTION =======================================================*)
(* card OF THE REMAINING / ndN IN THE fmap: *)
Definition P2
(m:fmap)(z:dart)(s:set):Prop:=
(card s < ndN m ->
card (Iter_rem_aux m z s) < ndN m)%nat.
Definition P2_bis
(m:fmap)(z:dart)(s:set):Prop:=
(card s <= ndN m ->
card (Iter_rem_aux m z s) <= ndN m)%nat.
(* THEN: *)
(* OK, IMPORTANT: COROLLARY*)
Definition Q1(m:fmap)(z:dart)(s:set):Prop:=
(card (Iter_rem_aux m z s) <= card s)%nat.
Definition Q2(m:fmap)(z:dart)(s:set):Prop:=
exds s (Iter (f m) (ndN m - card s)%nat z) ->
(card (Iter_rem_aux m z s) < card s)%nat.
(*========================================================== SOME LEMMAS, THEN RESULTS ABOUT PERIODICITY ===========================================================*)
(* L2 : *)
Definition PL2(m:fmap)(z t:dart)(x:set):Prop:=
inv_hmap m -> exd m z -> exds x t ->
let sr:= Iter_rem_aux m z x in
let zn0 := (Iter (f m) (ndN m - card x)%nat z) in
~exds sr t ->
exds x zn0 ->
~ exds (Iter_rem_aux m z (Ds x zn0)) t.
(* L3: *)
Definition PL3(m:fmap)(z t:dart)(x:set):Prop:=
inv_hmap m -> exd m z -> exds x t ->
let sr:= Iter_rem_aux m z x in
let zn0 := (Iter (f m) (ndN m - card x)%nat z) in
~exds sr t ->
exds x zn0.
(* EXTRACTION, OK: *)
Definition P4(m:fmap)(z t:dart)(s:set):Set:=
inv_hmap m -> exd m z -> exds s t ->
(card s <= ndN m)%nat ->
let sr:= Iter_rem_aux m z s in
let nr:= Iter_upb_aux m z s in
~ exds sr t ->
{i:nat | (i < nr)%nat /\ Iter (f m) i z = t}.
(* IF t IS REMOVED, THERE EXISTS i < nr, S.T. t IS THE ith ITERATED: OK *)
(* THIS APPLIES TO THE nr-th ITERATED *)
(* A RESULT OF PERIODICITY: *)
(* ITS INVERSE: *)
(* AND n TIMES: *)
(* PERIODICITY + n TIMES: *)
(* IMMEDIATE: USEFUL *)
(* IMMEDIATE: USEFUL *)
(*==========================================================  nr IS THE LOWEST PERIOD...  ===========================================================*)
Definition diff_int_aux
(m:fmap)(z:dart)(a b:nat)(t:dart): Prop:=
forall i : nat, (a <= i <= b)%nat ->
Iter (f m) i z <> t.
(* DIFFERENCE IN AN INTERVAL *)
Definition diff_int
(m:fmap)(z:dart)(a b:nat): Prop:=
forall i j : nat, (a <= i /\ i < j /\ j <= b)%nat ->
Iter (f m) i z <> Iter (f m) j z.
(* EXISTENCY Of THE z^i IN AN INTERVAL *)
Definition exds_int(m:fmap)(z:dart)(a b:nat)(s:set):Prop:=
forall i:nat, (a <= i <= b)%nat ->
exds s (Iter (f m) i z).
(* OK: *)
(* OK: *)
(* OK: ALL z^i FOR n0 <=i <= nr-1 EXIST IN s: *)
Definition P6(m:fmap)(z:dart)(s:set):Prop:=
inv_hmap m ->
(card s <= ndN m ->
let n0:= ndN m - card s in
let nr:= Iter_upb_aux m z s in
exds s (Iter (f m) n0 z) ->
exds_int m z n0 (nr - 1) s)%nat.
(* OK: LONG... *)
(* OK: FOR ALL n0 < j <= nr-1, z^n0 <> z^j: LENGHT: SYMPLIFY: TOO MUCH omegas... *)
Definition P7(m:fmap)(z:dart)(s:set):Prop:=
inv_hmap m ->
(card s <= ndN m ->
let n0:= ndN m - card s in
let nr:= Iter_upb_aux m z s in
exds s (Iter (f m) n0 z) ->
forall j:nat, n0 < j <= nr - 1 ->
Iter (f m) n0 z <> Iter (f m) j z)%nat.
(* OK: FOR ALL n0 <= i < j <= nr-1, z^i <> z^j: LENGHT: SYMPLIFY: TOO MUCH omegas... *)
Definition P8(m:fmap)(z:dart)(s:set):Prop:=
inv_hmap m ->
(card s <= ndN m ->
let n0:= ndN m - card s in
let nr:= Iter_upb_aux m z s in
exds s (Iter (f m) n0 z) ->
diff_int m z n0 (nr - 1))%nat.
(* ALL DARTS IN AN f-ORBIT ARE DISTINCT: *)
Definition diff_orb(m:fmap)(z:dart):Prop:=
let nr:= Iter_upb_aux m z (fmap_to_set m) in
(diff_int m z 0 (nr - 1))%nat.
intros.
unfold diff_orb in |- *.
generalize (nd_card m).
intro.
assert (ndN m - card (fmap_to_set m) = 0)%nat.
rewrite H1.
omega.
cut
(diff_int m z (ndN m - card (fmap_to_set m))
(Iter_upb_aux m z (fmap_to_set m) - 1))%nat.
rewrite H2.
tauto.
apply LP8.
tauto.
rewrite H1.
apply le_refl.
rewrite H2.
simpl in |- *.
generalize (exd_exds m z).
tauto.
Qed.
(* OK: nr IS A PERIOD OF THE f-ORBIT (IN FACT, IT IS THE LOWEST ONE, SINCE n0 = 0 AND ALL z^i DIFFER FROM z = z^n0 = z^0, FOR n0 < i <= nr-1) *)
(* WE HAVE: z^(i + n*p) = z^i FOR ALL i *)
(* WE HAVE: z^i = z^(i mod p) FOR ALL i *)
(* RECALL: modulo : forall n : nat, n > 0 -> forall m : nat, {r : nat | exists q : nat, m = q * n + r /\ n > r} *)
Export Compare.
(* ALL DARTS IN AN f-ORBIT HAVE THE SAME PERIOD: *)
(* UNICITY OF THE INDICE mod p: *)
(*=========================================================== PATHS in f-ORBITS: ==========================================================*)
(* REFLEXIVE EXISTENCE OF A PATH: *)
Definition expo(m:fmap)(z t:dart):Prop:=
exd m z /\ exists i:nat, Iter (f m) i z = t.
(* FOR THE DECIDABILITY: ... *)
Definition expo1
(m:fmap)(z t:dart):Prop:=
exd m z /\
let p:= Iter_upb m z in
exists j:nat, (j < p)%nat /\ Iter (f m) j z = t.
(* OK, GIVES THE "SMALLEST" INDICE j ST zj = zi: *)
Definition modulo(m:fmap)(z:dart)(i:dart)
(hi:inv_hmap m)(he:exd m z):nat.
(* REFLEXIVITY: *)

Lemma expo_refl:
forall(m:fmap)(z:dart), exd m z -> expo m z z.