(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
(* définition des fonctions de modification des adresses *)
Definition uad_conv_0 (a : ad) : ad :=
match a with
| N0 => N0
| Npos p => Npos (xO p)
end.
Definition uad_conv_1 (a : ad) : ad :=
match a with
| N0 => Npos 1
| Npos p => Npos (xI p)
end.
(* calcul des automates modifiés *)
Fixpoint upl_conv_0 (p : prec_list) : prec_list :=
match p with
| prec_empty => prec_empty
| prec_cons a p0 p1 =>
prec_cons (uad_conv_0 a) (upl_conv_0 p0) (upl_conv_0 p1)
end.
Fixpoint upl_conv_1 (p : prec_list) : prec_list :=
match p with
| prec_empty => prec_empty
| prec_cons a p0 p1 =>
prec_cons (uad_conv_1 a) (upl_conv_1 p0) (upl_conv_1 p1)
end.
Fixpoint umpl_conv_0 (s : state) : state :=
match s with
| M0 => M0 prec_list
| M1 a p => M1 prec_list a (upl_conv_0 p)
| M2 p0 p1 => M2 prec_list (umpl_conv_0 p0) (umpl_conv_0 p1)
end.
Fixpoint umpl_conv_1 (s : state) : state :=
match s with
| M0 => M0 prec_list
| M1 a p => M1 prec_list a (upl_conv_1 p)
| M2 p0 p1 => M2 prec_list (umpl_conv_1 p0) (umpl_conv_1 p1)
end.
Fixpoint udta_conv_0_aux (d : preDTA) : preDTA :=
match d with
| M0 => M0 state
| M1 a s => M1 state a (umpl_conv_0 s)
| M2 s0 s1 => M2 state (udta_conv_0_aux s0) (udta_conv_0_aux s1)
end.
Fixpoint udta_conv_1_aux (d : preDTA) : preDTA :=
match d with
| M0 => M0 state
| M1 a s => M1 state a (umpl_conv_1 s)
| M2 s0 s1 => M2 state (udta_conv_1_aux s0) (udta_conv_1_aux s1)
end.
Definition udta_conv_0 (d : preDTA) : preDTA :=
M2 state (udta_conv_0_aux d) (M0 state).
Definition udta_conv_1 (d : preDTA) : preDTA :=
M2 state (M0 state) (udta_conv_1_aux d).
(* lemmes d'injectivité *)

Lemma upl_conv_1_inj :
forall p0 p1 : prec_list, upl_conv_1 p0 = upl_conv_1 p1 -> p0 = p1.