(* insertion d'un état *)

Definition insert_state (d : preDTA) (a : ad) (s : state) : preDTA :=
  MapPut state d a s.Definition insert_main_state_0 (d : preDTA) (a : ad) 
  (s : state) : DTA := dta (insert_state d a s) a.Definition insert_main_state (d : preDTA) (s : state) : DTA :=
  insert_main_state_0 d (new_preDTA_ad d) s.Definition insert_ostate (d : preDTA) (a : ad) (o : option state) : preDTA :=
  match o with
  | None => d
  | Some s => MapPut state d a s
  end.Definition insert_main_ostate_0 (d : preDTA) (a : ad) 
  (o : option state) : DTA := dta (insert_ostate d a o) a.

(* Specifications: *)
Lemma insert_ostate_0 : forall (d : preDTA) (a : ad) (s : state) (a0 : ad) (t : term), preDTA_ref_ok d -> MapGet state d a = None -> a <> a0 -> (reconnaissance d a0 t <-> reconnaissance (insert_ostate d a (Some s)) a0 t).
Lemma insert_ostate_1 : forall (d0 d1 : preDTA) (a0 a1 a : ad) (s s0 s1 s0' s1' : state) (t : term), MapGet state d0 a0 = Some s0 -> MapGet state d1 a1 = Some s1 -> MapGet state (u_merge d0 d1) (uad_conv_0 a0) = Some s0' -> MapGet state (u_merge d0 d1) (uad_conv_1 a1) = Some s1' -> preDTA_ref_ok (u_merge d0 d1) -> MapGet state (u_merge d0 d1) a = None -> a <> uad_conv_0 a0 -> (reconnaissance d0 a0 t <-> reconnaissance (insert_ostate (u_merge d0 d1) a (Some s)) (uad_conv_0 a0) t).
Lemma insert_ostate_2 : forall (d0 d1 : preDTA) (a0 a1 a : ad) (s s0 s1 s0' s1' : state) (t : term), MapGet state d0 a0 = Some s0 -> MapGet state d1 a1 = Some s1 -> MapGet state (u_merge d0 d1) (uad_conv_0 a0) = Some s0' -> MapGet state (u_merge d0 d1) (uad_conv_1 a1) = Some s1' -> preDTA_ref_ok (u_merge d0 d1) -> MapGet state (u_merge d0 d1) a = None -> a <> uad_conv_1 a1 -> (reconnaissance d1 a1 t <-> reconnaissance (insert_ostate (u_merge d0 d1) a (Some s)) (uad_conv_1 a1) t).
Lemma insert_ostate_3 : forall (d0 d1 : preDTA) (a0 a1 a : ad) (s s0 s1 s0' s1' : state) (t : term), MapGet state d0 a0 = Some s0 -> MapGet state d1 a1 = Some s1 -> MapGet state (u_merge d0 d1) (uad_conv_0 a0) = Some s0' -> MapGet state (u_merge d0 d1) (uad_conv_1 a1) = Some s1' -> preDTA_ref_ok (u_merge d0 d1) -> MapGet state (u_merge d0 d1) a = None -> a <> uad_conv_0 a0 -> (reconnaissance (insert_ostate (u_merge d0 d1) a (Some s)) (uad_conv_0 a0) t <-> state_reconnait (insert_ostate (u_merge d0 d1) a (Some s)) s0' t).
Lemma insert_ostate_4 : forall (d0 d1 : preDTA) (a0 a1 a : ad) (s s0 s1 s0' s1' : state) (t : term), MapGet state d0 a0 = Some s0 -> MapGet state d1 a1 = Some s1 -> MapGet state (u_merge d0 d1) (uad_conv_0 a0) = Some s0' -> MapGet state (u_merge d0 d1) (uad_conv_1 a1) = Some s1' -> preDTA_ref_ok (u_merge d0 d1) -> MapGet state (u_merge d0 d1) a = None -> a <> uad_conv_1 a1 -> (reconnaissance (insert_ostate (u_merge d0 d1) a (Some s)) (uad_conv_1 a1) t <-> state_reconnait (insert_ostate (u_merge d0 d1) a (Some s)) s1' t).
Lemma insert_ostate_5 : forall (d0 d1 : preDTA) (a0 a1 a : ad) (s0 s1 s0' s1' : state) (t : term), mpl_compat s0' s1' -> MapGet state d0 a0 = Some s0 -> MapGet state d1 a1 = Some s1 -> MapGet state (u_merge d0 d1) (uad_conv_0 a0) = Some s0' -> MapGet state (u_merge d0 d1) (uad_conv_1 a1) = Some s1' -> preDTA_ref_ok (u_merge d0 d1) -> MapGet state (u_merge d0 d1) a = None -> a <> uad_conv_0 a0 -> a <> uad_conv_1 a1 -> (state_reconnait (insert_ostate (u_merge d0 d1) a (Some (union_mpl s0' s1'))) (union_mpl s0' s1') t <-> state_reconnait (insert_ostate (u_merge d0 d1) a (Some (union_mpl s0' s1'))) s0' t \/ state_reconnait (insert_ostate (u_merge d0 d1) a (Some (union_mpl s0' s1'))) s1' t).
Lemma insert_ostate_6 : forall (d0 d1 : preDTA) (a0 a1 a : ad) (s0 s1 s0' s1' : state) (t : term), mpl_compat s0' s1' -> MapGet state d0 a0 = Some s0 -> MapGet state d1 a1 = Some s1 -> MapGet state (u_merge d0 d1) (uad_conv_0 a0) = Some s0' -> MapGet state (u_merge d0 d1) (uad_conv_1 a1) = Some s1' -> preDTA_ref_ok (u_merge d0 d1) -> MapGet state (u_merge d0 d1) a = None -> a <> uad_conv_0 a0 -> a <> uad_conv_1 a1 -> (state_reconnait (insert_ostate (u_merge d0 d1) a (Some (union_mpl s0' s1'))) (union_mpl s0' s1') t <-> reconnaissance (insert_ostate (u_merge d0 d1) a (Some (union_mpl s0' s1'))) a t).
Lemma insert_ostate_7 : forall (d0 d1 : preDTA) (a0 a1 a : ad) (s0 s1 s0' s1' : state) (t : term), mpl_compat s0' s1' -> MapGet state d0 a0 = Some s0 -> MapGet state d1 a1 = Some s1 -> MapGet state (u_merge d0 d1) (uad_conv_0 a0) = Some s0' -> MapGet state (u_merge d0 d1) (uad_conv_1 a1) = Some s1' -> preDTA_ref_ok (u_merge d0 d1) -> MapGet state (u_merge d0 d1) a = None -> a <> uad_conv_0 a0 -> a <> uad_conv_1 a1 -> (reconnaissance d0 a0 t \/ reconnaissance d1 a1 t <-> reconnaissance (insert_ostate (u_merge d0 d1) a (Some (union_mpl s0' s1'))) a t).
Lemma insert_ostate_8 : forall (d0 d1 : preDTA) (a0 a1 a : ad) (s0 s1 s0' s1' : state) (t : term), mpl_compat s0' s1' -> MapGet state d0 a0 = Some s0 -> MapGet state d1 a1 = Some s1 -> MapGet state (u_merge d0 d1) (uad_conv_0 a0) = Some s0' -> MapGet state (u_merge d0 d1) (uad_conv_1 a1) = Some s1' -> preDTA_ref_ok (u_merge d0 d1) -> a = new_preDTA_ad (u_merge d0 d1) -> (reconnaissance d0 a0 t \/ reconnaissance d1 a1 t <-> reconnaissance (insert_ostate (u_merge d0 d1) a (Some (union_mpl s0' s1'))) a t).
Lemma upl_conv_0_occur : forall (pl : prec_list) (a : ad), prec_occur (upl_conv_0 pl) (uad_conv_0 a) -> prec_occur pl a.
Lemma upl_conv_1_occur : forall (pl : prec_list) (a : ad), prec_occur (upl_conv_1 pl) (uad_conv_1 a) -> prec_occur pl a.
Lemma upl_conv_0_occur_in_img : forall (pl : prec_list) (a : ad), prec_occur (upl_conv_0 pl) a -> exists b : ad, a = uad_conv_0 b.
Lemma upl_conv_1_occur_in_img : forall (pl : prec_list) (a : ad), prec_occur (upl_conv_1 pl) a -> exists b : ad, a = uad_conv_1 b.
Lemma u_conv_0_ref_ok : forall d : preDTA, preDTA_ref_ok d -> preDTA_ref_ok (udta_conv_0 d).
Lemma u_conv_1_ref_ok : forall d : preDTA, preDTA_ref_ok d -> preDTA_ref_ok (udta_conv_1 d).
Lemma u_merge_ref_ok : forall d0 d1 : preDTA, preDTA_ref_ok d0 -> preDTA_ref_ok d1 -> preDTA_ref_ok (u_merge d0 d1).
Lemma upl_conv_compat_0_0 : forall p0 p1 : prec_list, pl_compat p0 p1 -> pl_compat (upl_conv_0 p0) (upl_conv_0 p1).
Lemma upl_conv_compat_0_1 : forall p0 p1 : prec_list, pl_compat p0 p1 -> pl_compat (upl_conv_0 p0) (upl_conv_1 p1).
Lemma upl_conv_compat_1_0 : forall p0 p1 : prec_list, pl_compat p0 p1 -> pl_compat (upl_conv_1 p0) (upl_conv_0 p1).
Lemma upl_conv_compat_1_1 : forall p0 p1 : prec_list, pl_compat p0 p1 -> pl_compat (upl_conv_1 p0) (upl_conv_1 p1).
Lemma umpl_conv_0_compat : forall s0 s1 : state, mpl_compat s0 s1 -> mpl_compat (umpl_conv_0 s0) (umpl_conv_0 s1).
Lemma umpl_conv_1_compat : forall s0 s1 : state, mpl_compat s0 s1 -> mpl_compat (umpl_conv_1 s0) (umpl_conv_1 s1).
Lemma umpl_conv_0_1_compat : forall s0 s1 : state, mpl_compat s0 s1 -> mpl_compat (umpl_conv_0 s0) (umpl_conv_1 s1).
Lemma udta_conv_0_compat : forall d : preDTA, dta_correct d -> dta_correct (udta_conv_0 d).
Lemma udta_conv_1_compat : forall d : preDTA, dta_correct d -> dta_correct (udta_conv_1 d).
Lemma udta_conv_0_1_compat : forall d0 d1 : preDTA, dta_compat d0 d1 -> dta_compat (udta_conv_0 d0) (udta_conv_1 d1).
Lemma insert_ostate_9 : forall (d0 d1 : preDTA) (a0 a1 a : ad) (s0' s1' : state) (t : term), preDTA_ref_ok d0 -> preDTA_ref_ok d1 -> dta_compat d0 d1 -> MapGet state (u_merge d0 d1) (uad_conv_0 a0) = Some s0' -> MapGet state (u_merge d0 d1) (uad_conv_1 a1) = Some s1' -> a = new_preDTA_ad (u_merge d0 d1) -> (reconnaissance d0 a0 t \/ reconnaissance d1 a1 t <-> reconnaissance (insert_ostate (u_merge d0 d1) a (Some (union_mpl s0' s1'))) a t).