(* fonctions réciproques gauche et droite de iad_conv *)

Inductive ad_couple : Set :=
    cpla : ad -> ad -> ad_couple.(* fonctions réciproques gauche et droite de iad_conv *)

Inductive ad_couple : Set :=
    cpla : ad -> ad -> ad_couple.Fixpoint iad_conv_inv_0 (p : positive) : ad_couple :=
  match p with
  | xH => cpla (Npos 1) N0
  | xO xH => cpla N0 (Npos 1)
  | xI xH => cpla (Npos 1) (Npos 1)
  | xO (xO p') =>
      match iad_conv_inv_0 p' with
      | cpla N0 N0 => cpla N0 N0
      | cpla N0 (Npos p1) => cpla N0 (Npos (xO p1))
      | cpla (Npos p0) N0 => cpla (Npos (xO p0)) N0
      | cpla (Npos p0) (Npos p1) => cpla (Npos (xO p0)) (Npos (xO p1))
      end
  | xO (xI p') =>
      match iad_conv_inv_0 p' with
      | cpla N0 N0 => cpla N0 (Npos 1)
      | cpla N0 (Npos p1) => cpla N0 (Npos (xI p1))
      | cpla (Npos p0) N0 => cpla (Npos (xO p0)) (Npos 1)
      | cpla (Npos p0) (Npos p1) => cpla (Npos (xO p0)) (Npos (xI p1))
      end
  | xI (xO p') =>
      match iad_conv_inv_0 p' with
      | cpla N0 N0 => cpla (Npos 1) N0
      | cpla N0 (Npos p1) => cpla (Npos 1) (Npos (xO p1))
      | cpla (Npos p0) N0 => cpla (Npos (xI p0)) N0
      | cpla (Npos p0) (Npos p1) => cpla (Npos (xI p0)) (Npos (xO p1))
      end
  | xI (xI p') =>
      match iad_conv_inv_0 p' with
      | cpla N0 N0 => cpla (Npos 1) (Npos 1)
      | cpla N0 (Npos p1) => cpla (Npos 1) (Npos (xI p1))
      | cpla (Npos p0) N0 => cpla (Npos (xI p0)) (Npos 1)
      | cpla (Npos p0) (Npos p1) => cpla (Npos (xI p0)) (Npos (xI p1))
      end
  end.Definition iad_conv_inv (a : ad) : ad_couple :=
  match a with
  | N0 => cpla N0 N0
  | Npos p => iad_conv_inv_0 p
  end.

(* Specifications: *)
Lemma iad_inv_0 : forall p : positive, iad_conv_inv_0 (iad_conv_aux_0 p) = cpla N0 (Npos p).
Lemma iad_inv_1 : forall p : positive, iad_conv_inv_0 (iad_conv_aux_1 p) = cpla (Npos p) N0.
Lemma iad_inv_2 : forall p0 p1 : positive, iad_conv_inv_0 (iad_conv_aux_2 p0 p1) = cpla (Npos p0) (Npos p1).
Lemma iad_inv_inv_0 : forall a0 a1 : ad, iad_conv_inv (iad_conv a0 a1) = cpla a0 a1.
Lemma iad_inv_inv_1 : forall a a0 a1 : ad, iad_conv_inv a = cpla a0 a1 -> iad_conv a0 a1 = a.