(* Changing k-links: effect: breaking/merging of orbits *)

(* Precondition for hmaps: *)

Definition prec_lh (m:fmap)(k:dim)(x y:dart)
  := exd m x /\ exd m y /\ y <> A m k x.(* Note that the construction of fixpoints is allowed: *)

Definition l (m:fmap)(k:dim)(x y:dart) :=
   let xk  := (A m k x) in
   let y_k := (A_1 m k y) in
   let m1 := (B_1 (B m k x) k y) in
   (L (L m1 k x y) k y_k xk).

(* Specifications: *)
Lemma y_xk_vs_yk_x : forall(m:fmap)(k:dim)(x y:dart), inv_hmap m -> exd m x -> exd m y -> let xk:= A m k x in let yk:= A_1 m k y in y <> xk <-> yk <> x.
Lemma inv_qhmap_l_11: forall (m:fmap)(k:dim)(x y:dart), inv_qhmap m -> prec_lh m k x y -> inv_qhmap (B_1 (B m k x) k y).
Lemma inv_qhmap_l_12: forall (m:fmap)(k:dim)(x y:dart), inv_qhmap m -> prec_lh m k x y -> prec_Lq (B_1 (B m k x) k y) k x y.
Lemma inv_hmap_l_13: forall (m:fmap)(k:dim)(x y:dart), inv_hmap m -> prec_lh m k x y -> prec_Lq (L (B_1 (B m k x) k y) k x y) k (A_1 m k y) (A m k x).
Lemma inv_hmap_l_1: forall (m:fmap)(k:dim)(x y:dart), inv_hmap m -> prec_lh m k x y -> inv_qhmap (l m k x y).
Lemma inv_hmap_l_2: forall (m:fmap)(k:dim)(x y:dart), inv_hmap m -> prec_lh m k x y -> (forall (x0 : dart) (k0 : dim), exd (l m k x y) x0 -> succ (l m k x y) k0 x0 /\ pred (l m k x y) k0 x0).
Theorem inv_hmap_l: forall (m:fmap)(k:dim)(x y:dart), inv_hmap m -> prec_lh m k x y -> inv_hmap (l m k x y).
Theorem A_A_1_v : forall (m:fmap)(j:dim)(x z : dart), inv_hmap m -> A v j z = nil /\ A_1 v j z = nil.
Theorem A_A_1_i : forall (m:fmap)(j:dim)(x z : dart), inv_hmap m -> prec_i m x -> (A (i m x) j z = if eq_dart_dec z x then x else A m j z) /\ (A_1 (i m x) j z = if eq_dart_dec z x then x else A_1 m j z).
Theorem A_i : forall (m:fmap)(j:dim)(x z : dart), inv_hmap m -> prec_i m x -> (A (i m x) j z = if eq_dart_dec z x then x else A m j z).
Theorem A_1_i : forall (m:fmap)(j:dim)(x z : dart), inv_hmap m -> prec_i m x -> (A_1 (i m x) j z = if eq_dart_dec z x then x else A_1 m j z).
Theorem A_A_1_l : forall (m:fmap)(k j:dim)(x y z : dart), inv_hmap m -> prec_lh m k x y -> (A (l m k x y) j z = if eq_dim_dec j k then if eq_dart_dec z x then y else if eq_dart_dec z (A_1 m k y) then A m k x else A m k z else A m j z) /\ (A_1 (l m k x y) j z = if eq_dim_dec j k then if eq_dart_dec z y then x else if eq_dart_dec z (A m k x) then A_1 m k y else A_1 m k z else A_1 m j z).
Theorem A_l : forall (m:fmap)(k j:dim)(x y z : dart), inv_hmap m -> prec_lh m k x y -> (A (l m k x y) j z = if eq_dim_dec j k then if eq_dart_dec z x then y else if eq_dart_dec z (A_1 m k y) then A m k x else A m k z else A m j z).
Theorem A_1_l : forall (m:fmap)(k j:dim)(x y z : dart), inv_hmap m -> prec_lh m k x y -> (A_1 (l m k x y) j z = if eq_dim_dec j k then if eq_dart_dec z y then x else if eq_dart_dec z (A m k x) then A_1 m k y else A_1 m k z else A_1 m j z).