(* union de deux états dans un meme preDTA *)
(* définition d'un état *)
Fixpoint union_pl (pl0 : prec_list) : prec_list -> prec_list :=
fun pl1 : prec_list =>
match pl0 with
| prec_empty => pl1
| prec_cons a pl00 pl01 => prec_cons a pl00 (union_pl pl01 pl1)
end.
Fixpoint union_mpl_0 (c : ad) (pl : prec_list) (s : state) {struct s} :
state :=
match s with
| M0 => M1 prec_list c pl
| M1 c0 pl0 =>
if Neqb c c0
then M1 prec_list c (union_pl pl pl0)
else MapMerge prec_list (M1 prec_list c pl) (M1 prec_list c0 pl0)
| M2 s0 s1 =>
match c with
| N0 => M2 prec_list (union_mpl_0 N0 pl s0) s1
| Npos p =>
match p with
| xH => M2 prec_list s0 (union_mpl_0 N0 pl s1)
| xO p' => M2 prec_list (union_mpl_0 (Npos p') pl s0) s1
| xI p' => M2 prec_list s0 (union_mpl_0 (Npos p') pl s1)
end
end
end.
Fixpoint union_mpl (s0 : state) : state -> state :=
fun s1 : state =>
match s0, s1 with
| M0, M0 => M0 prec_list
| M0, M2 s10 s11 => M2 prec_list s10 s11
| _, M1 c1 pl1 => union_mpl_0 c1 pl1 s0
| M1 c0 pl0, _ => union_mpl_0 c0 pl0 s1
| M2 s00 s01, M0 => M2 prec_list s00 s01
| M2 s00 s01, M2 s10 s11 =>
M2 prec_list (union_mpl s00 s10) (union_mpl s01 s11)
end.

Lemma union_pl_0d :
forall (d : preDTA) (pl0 pl1 : prec_list) (tl : term_list),
pl_compat pl0 pl1 ->
liste_reconnait d pl0 tl -> liste_reconnait d (union_pl pl0 pl1) tl.