Section gram4.
Variable X V1 R1 : Ensf.
Variable S1 : Elt.
Variable V2 R2 : Ensf.
Variable S2 : Elt.
Variable S : Elt.
Let C := Gunion_disj_p V1 R1 S1 V2 R2 S2 S.
Let Vu := fst C.
Let C' := snd C.
Let Ru := fst C'.
Let Su := snd C'.
prolog [ isGram2 union_inter ] 5.
(*Intro G1. Intro G2. Apply union_inter. Apply isGram2 with R1 S1; Assumption. Apply isGram2 with R2 S2; Assumption.*)
Qed.
intros G_1 G_2 N_dans_S_X.
unfold inter in |- *.
split.
auto.
split.
auto.
intros x dans_x_X dans_x_Vu.
absurd (dans x X).
cut (S = x :>Elt \/ dans x (union V1 V2)). (**)
intro temp; elim temp; clear temp.
intros egal_S_x.
rewrite <- egal_S_x; assumption.
intro dans_x_V1_u_V2.
prolog [ inter_X_V1_u_V2 sym_inter inter_dans ] 4.
(*Apply inter_dans with (union V1 V2). Apply sym_inter. Apply inter_X_V1_u_V2;Assumption.  Assumption.*)
(**)auto.  assumption. Qed.  Lemma Gunion_disj_Regles : isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> Regles X Vu Ru. intros. unfold Vu, Ru in |- *; simpl in |- *. apply Regles_add. apply Regles_add. apply Regles_add2. change (Regles X (fst (Gunion V1 R1 V2 R2)) (snd (Gunion V1 R1 V2 R2))) in |- *. prolog [ Gunion_Regles ] 2. (*Apply Gunion_Regles with S1 S2;Auto.*)
auto.
apply inmonoid_cons.
trivial.
cut (dans S2 V2);
[ auto
| prolog [ isGram3 ] 2(*Apply isGram3 with X R2;Assumption*) ].
auto.
apply inmonoid_cons.
trivial.
cut (dans S1 V1);
[ auto
| prolog [ isGram3 ] 2 (*Apply isGram3 with X R1;Assumption*) ].
Qed.
intros N_dans_X N_dans_V1 N_dans_V2 Re_1 Re_2 inter_X_V1_V2_empty u v
Der_Ru_u.
elim Der_Ru_u.
intros u0 v0 A dans_couple_Ru inmon_cons_A_v0.
apply Derive1.
cut
(couple S (word (cons S1 nil)) = couple A (word u0) :>Elt \/
dans (couple A (word u0))
(add (couple S (word (cons S2 nil))) (union R1 R2))). (**)
intro temp; elim temp; clear temp.
intro egal_S.
absurd (dans S X \/ dans S V1).
red in |- *.
intro temp; elim temp; clear temp.
exact N_dans_X.
exact N_dans_V1.
apply dans_union.
replace S with A.
prolog [ inmonoid_cons_inv2 ] 2.
(*Apply inmonoid_cons_inv2 with v0;Assumption.*)
injection egal_S; auto.
intro dans_couple_add.
cut
(couple S (word (cons S2 nil)) = couple A (word u0) :>Elt \/
dans (couple A (word u0)) (union R1 R2)). (***)
intro temp; elim temp; clear temp.
intro egal_S.
absurd (dans S X \/ dans S V1).
red in |- *.
intro temp; elim temp; auto.
apply dans_union.
replace S with A.
prolog [ inmonoid_cons_inv2 ] 2.
(*Apply inmonoid_cons_inv2 with v0;Assumption.*)
injection egal_S; auto.
intro dans_couple_union.
cut (dans (couple A (word u0)) R1 \/ dans (couple A (word u0)) R2). (****)
(*Intuition.*)intro temp; elim temp; clear temp. auto. intro dans_R2. absurd (inter (union X V1) V2 empty). red in |- *. unfold inter in |- *. (*Intuition.*)intro temp; elim temp; clear temp. intros HH temp; elim temp; clear temp; intros HHH HHHH. (*Intros.*)
prolog [ Regles_inv1 inmonoid_cons_inv2 dans_empty_imp_P ] 4.
(*Intro temp;Elim temp;Clear temp. Intros incl_empty_X_V1 temp;Elim temp;Clear temp. Intros incl_empty_V2 imp.  Apply dans_empty_imp_P with A. Apply imp. Apply inmonoid_cons_inv2 with v0;Assumption. Apply Regles_inv1 with X R2 (word u0); Assumption.*)
assumption.
(****)auto.  (***)auto.  (**)auto.  prolog [ inmonoid_cons_inv Derive2 ] 10. (*Intros u0 v0 x Der_Ru imp inmon_cons_x_u0. Apply Derive2. Apply imp. Apply inmonoid_cons_inv with x. Assumption.*)
Qed.
prolog [ in_mon_X_Der_imp_inmon_X ] 7.
(*Intros. Apply in_mon_X_Der_imp_inmon_X with R1 u;Assumption.*)
Qed.

Lemma inmon_Der_imp_inmon_d :
~ dans S X ->
~ dans S V1 ->
~ dans S V2 ->
forall u v : Word,
isGram X V1 R1 S1 ->
isGram X V2 R2 S2 ->
inter V1 V2 empty ->
inmonoid (union X V1) u -> Derive Ru u v -> inmonoid (union X V1) v.