--- /dev/null
+(**************************************************************************)
+(* ___ *)
+(* ||M|| *)
+(* ||A|| A project by Andrea Asperti *)
+(* ||T|| *)
+(* ||I|| Developers: *)
+(* ||T|| The HELM team. *)
+(* ||A|| http://helm.cs.unibo.it *)
+(* \ / *)
+(* \ / This file is distributed under the terms of the *)
+(* v GNU General Public License Version 2 *)
+(* *)
+(**************************************************************************)
+
+include "arithmetics/lstar.ma".
+
+(* PROPERTIES OF NAT-LABELED REFLEXIVE AND TRANSITIVE CLOSURE ***************)
+
+definition llstar: ∀A:Type[0]. ∀B. (A→relation B) → nat → (A→relation B) ≝
+ λA,B,R,l,a. lstar … (R a) l.
/2 width=3/
qed.
+lemma lstar_dx: ∀B,R,l,b1,b. lstar B R l b1 b → ∀b2. R b b2 →
+ lstar B R (l+1) b1 b2.
+#B #R #l #b1 #b #H @(lstar_ind_l … l b1 H) -l -b1 /2 width=1/ /3 width=3/
+qed.
+
lemma lstar_inv_O: ∀B,R,l,b1,b2. lstar B R l b1 b2 → 0 = l → b1 = b2.
#B #R #l #b1 #b2 * -l -b1 -b2 //
#b1 #b #_ #l #b2 #_ <plus_n_Sm #H destruct
elim (IHl1 … Hb2) -IHl1 -Hb2 /3 width=3/
qed-.
-lemma lstar_dx: ∀B,R,l,b1,b. lstar B R l b1 b → ∀b2. R b b2 →
- lstar B R (l+1) b1 b2.
-#B #R #l #b1 #b #H @(lstar_ind_l … l b1 H) -l -b1 /2 width=1/ /3 width=3/
-qed.
+lemma lstar_inv_S_dx: ∀B,R,l,b1,b2. lstar B R (l+1) b1 b2 →
+ ∃∃b. lstar B R l b1 b & R b b2.
+#B #R #l #b1 #b2 #H
+elim (lstar_inv_ltransitive B R … H) -H #b #Hb1 #H
+lapply (lstar_inv_step B R … H) -H /2 width=3/
+qed-.
inductive lstar_r (B:Type[0]) (R: relation B): ℕ → relation B ≝
| lstar_r_O: ∀b. lstar_r B R 0 b b
#B #R #b1 #P #H1 #H2 #l #b2 #Hb12
@(lstar_ind_r_aux … H1 H2 … Hb12) //
qed-.
+
+lemma lstar_Conf3: ∀A,B,S,R. Conf3 A B S R → ∀l. Conf3 A B S (lstar … R l).
+#A #B #S #R #HSR #l #b #a1 #Ha1 #a2 #H @(lstar_ind_r … l a2 H) -l -a2 // /2 width=3/
+qed-.
definition confluent: ∀A. predicate (relation A) ≝ λA,R.
∀a0. confluent1 … R a0.
+(* triangular confluence of two relations *)
+definition Conf3: ∀A,B. relation2 A B → relation A → Prop ≝ λA,B,S,R.
+ ∀b,a1. S a1 b → ∀a2. R a1 a2 → S a2 b.
+
(* Reflexive closure ************)
definition RC: ∀A:Type[0]. relation A → relation A ≝
@(TC_ind_dx … P ? H … Ha12) /3 width=4/
qed-.
-definition Conf3: ∀A,B. relation2 A B → relation A → Prop ≝ λA,B,S,R.
- ∀b,a1. S a1 b → ∀a2. R a1 a2 → S a2 b.
-
lemma TC_Conf3: ∀A,B,S,R. Conf3 A B S R → Conf3 A B S (TC … R).
#A #B #S #R #HSR #b #a1 #Ha1 #a2 #H elim H -a2 /2 width=3/
qed.