src/HOL/Transitive_Closure.thy
changeset 22262 96ba62dff413
parent 22172 e7d6cb237b5e
child 22422 ee19cdb07528
--- a/src/HOL/Transitive_Closure.thy	Wed Feb 07 17:26:49 2007 +0100
+++ b/src/HOL/Transitive_Closure.thy	Wed Feb 07 17:28:09 2007 +0100
@@ -7,7 +7,7 @@
 header {* Reflexive and Transitive closure of a relation *}
 
 theory Transitive_Closure
-imports Inductive
+imports Predicate
 uses "~~/src/Provers/trancl.ML"
 begin
 
@@ -20,56 +20,85 @@
   operands to be atomic.
 *}
 
-consts
-  rtrancl :: "('a \<times> 'a) set => ('a \<times> 'a) set"    ("(_^*)" [1000] 999)
-
-inductive "r^*"
-  intros
-    rtrancl_refl [intro!, Pure.intro!, simp]: "(a, a) : r^*"
-    rtrancl_into_rtrancl [Pure.intro]: "(a, b) : r^* ==> (b, c) : r ==> (a, c) : r^*"
+inductive2
+  rtrancl :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool"   ("(_^**)" [1000] 1000)
+  for r :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
+where
+    rtrancl_refl [intro!, Pure.intro!, simp]: "r^** a a"
+  | rtrancl_into_rtrancl [Pure.intro]: "r^** a b ==> r b c ==> r^** a c"
 
-consts
-  trancl :: "('a \<times> 'a) set => ('a \<times> 'a) set"    ("(_^+)" [1000] 999)
+inductive2
+  trancl :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool"  ("(_^++)" [1000] 1000)
+  for r :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
+where
+    r_into_trancl [intro, Pure.intro]: "r a b ==> r^++ a b"
+  | trancl_into_trancl [Pure.intro]: "r^++ a b ==> r b c ==> r^++ a c"
 
-inductive "r^+"
-  intros
-    r_into_trancl [intro, Pure.intro]: "(a, b) : r ==> (a, b) : r^+"
-    trancl_into_trancl [Pure.intro]: "(a, b) : r^+ ==> (b, c) : r ==> (a,c) : r^+"
+constdefs
+  rtrancl_set :: "('a \<times> 'a) set => ('a \<times> 'a) set"    ("(_^*)" [1000] 999)
+  "r^* == Collect2 (member2 r)^**"
+
+  trancl_set :: "('a \<times> 'a) set => ('a \<times> 'a) set"    ("(_^+)" [1000] 999)
+  "r^+ == Collect2 (member2 r)^++"
 
 abbreviation
-  reflcl :: "('a \<times> 'a) set => ('a \<times> 'a) set"  ("(_^=)" [1000] 999) where
+  reflcl :: "('a => 'a => bool) => 'a => 'a => bool"  ("(_^==)" [1000] 1000) where
+  "r^== == join r op ="
+
+abbreviation
+  reflcl_set :: "('a \<times> 'a) set => ('a \<times> 'a) set"  ("(_^=)" [1000] 999) where
   "r^= == r \<union> Id"
 
 notation (xsymbols)
-  rtrancl  ("(_\<^sup>*)" [1000] 999) and
-  trancl  ("(_\<^sup>+)" [1000] 999) and
-  reflcl  ("(_\<^sup>=)" [1000] 999)
+  rtrancl  ("(_\<^sup>*\<^sup>*)" [1000] 1000) and
+  trancl  ("(_\<^sup>+\<^sup>+)" [1000] 1000) and
+  reflcl  ("(_\<^sup>=\<^sup>=)" [1000] 1000) and
+  rtrancl_set  ("(_\<^sup>*)" [1000] 999) and
+  trancl_set  ("(_\<^sup>+)" [1000] 999) and
+  reflcl_set  ("(_\<^sup>=)" [1000] 999)
 
 notation (HTML output)
-  rtrancl  ("(_\<^sup>*)" [1000] 999) and
-  trancl  ("(_\<^sup>+)" [1000] 999) and
-  reflcl  ("(_\<^sup>=)" [1000] 999)
+  rtrancl  ("(_\<^sup>*\<^sup>*)" [1000] 1000) and
+  trancl  ("(_\<^sup>+\<^sup>+)" [1000] 1000) and
+  reflcl  ("(_\<^sup>=\<^sup>=)" [1000] 1000) and
+  rtrancl_set  ("(_\<^sup>*)" [1000] 999) and
+  trancl_set  ("(_\<^sup>+)" [1000] 999) and
+  reflcl_set  ("(_\<^sup>=)" [1000] 999)
 
 
 subsection {* Reflexive-transitive closure *}
 
+lemma rtrancl_set_eq [pred_set_conv]: "(member2 r)^** = member2 (r^*)"
+  by (simp add: rtrancl_set_def)
+
+lemma reflcl_set_eq [pred_set_conv]: "(join (member2 r) op =) = member2 (r Un Id)"
+  by (simp add: expand_fun_eq)
+
+lemmas rtrancl_refl [intro!, Pure.intro!, simp] = rtrancl_refl [to_set]
+lemmas rtrancl_into_rtrancl [Pure.intro] = rtrancl_into_rtrancl [to_set]
+
 lemma r_into_rtrancl [intro]: "!!p. p \<in> r ==> p \<in> r^*"
   -- {* @{text rtrancl} of @{text r} contains @{text r} *}
   apply (simp only: split_tupled_all)
   apply (erule rtrancl_refl [THEN rtrancl_into_rtrancl])
   done
 
-lemma rtrancl_mono: "r \<subseteq> s ==> r^* \<subseteq> s^*"
+lemma r_into_rtrancl' [intro]: "r x y ==> r^** x y"
+  -- {* @{text rtrancl} of @{text r} contains @{text r} *}
+  by (erule rtrancl.rtrancl_refl [THEN rtrancl.rtrancl_into_rtrancl])
+
+lemma rtrancl_mono': "r \<le> s ==> r^** \<le> s^**"
   -- {* monotonicity of @{text rtrancl} *}
-  apply (rule subsetI)
-  apply (simp only: split_tupled_all)
+  apply (rule predicate2I)
   apply (erule rtrancl.induct)
-   apply (rule_tac [2] rtrancl_into_rtrancl, blast+)
+   apply (rule_tac [2] rtrancl.rtrancl_into_rtrancl, blast+)
   done
 
-theorem rtrancl_induct [consumes 1, induct set: rtrancl]:
-  assumes a: "(a, b) : r^*"
-    and cases: "P a" "!!y z. [| (a, y) : r^*; (y, z) : r; P y |] ==> P z"
+lemmas rtrancl_mono = rtrancl_mono' [to_set]
+
+theorem rtrancl_induct' [consumes 1, induct set: rtrancl]:
+  assumes a: "r^** a b"
+    and cases: "P a" "!!y z. [| r^** a y; r y z; P y |] ==> P z"
   shows "P b"
 proof -
   from a have "a = a --> P b"
@@ -77,6 +106,12 @@
   thus ?thesis by iprover
 qed
 
+lemmas rtrancl_induct [consumes 1, induct set: rtrancl_set] = rtrancl_induct' [to_set]
+
+lemmas rtrancl_induct2' =
+  rtrancl_induct'[of _ "(ax,ay)" "(bx,by)", split_rule,
+                 consumes 1, case_names refl step]
+
 lemmas rtrancl_induct2 =
   rtrancl_induct[of "(ax,ay)" "(bx,by)", split_format (complete),
                  consumes 1, case_names refl step]
@@ -95,6 +130,12 @@
 
 lemmas rtrancl_trans = trans_rtrancl [THEN transD, standard]
 
+lemma rtrancl_trans':
+  assumes xy: "r^** x y"
+  and yz: "r^** y z"
+  shows "r^** x z" using yz xy
+  by induct iprover+
+
 lemma rtranclE:
   assumes major: "(a::'a,b) : r^*"
     and cases: "(a = b) ==> P"
@@ -114,21 +155,25 @@
   apply (erule rtrancl_induct, auto) 
   done
 
-lemma converse_rtrancl_into_rtrancl:
-  "(a, b) \<in> r \<Longrightarrow> (b, c) \<in> r\<^sup>* \<Longrightarrow> (a, c) \<in> r\<^sup>*"
-  by (rule rtrancl_trans) iprover+
+lemma converse_rtrancl_into_rtrancl':
+  "r a b \<Longrightarrow> r\<^sup>*\<^sup>* b c \<Longrightarrow> r\<^sup>*\<^sup>* a c"
+  by (rule rtrancl_trans') iprover+
+
+lemmas converse_rtrancl_into_rtrancl = converse_rtrancl_into_rtrancl' [to_set]
 
 text {*
   \medskip More @{term "r^*"} equations and inclusions.
 *}
 
-lemma rtrancl_idemp [simp]: "(r^*)^* = r^*"
-  apply auto
-  apply (erule rtrancl_induct)
-   apply (rule rtrancl_refl)
-  apply (blast intro: rtrancl_trans)
+lemma rtrancl_idemp' [simp]: "(r^**)^** = r^**"
+  apply (auto intro!: order_antisym)
+  apply (erule rtrancl_induct')
+   apply (rule rtrancl.rtrancl_refl)
+  apply (blast intro: rtrancl_trans')
   done
 
+lemmas rtrancl_idemp [simp] = rtrancl_idemp' [to_set]
+
 lemma rtrancl_idemp_self_comp [simp]: "R^* O R^* = R^*"
   apply (rule set_ext)
   apply (simp only: split_tupled_all)
@@ -138,16 +183,22 @@
 lemma rtrancl_subset_rtrancl: "r \<subseteq> s^* ==> r^* \<subseteq> s^*"
 by (drule rtrancl_mono, simp)
 
-lemma rtrancl_subset: "R \<subseteq> S ==> S \<subseteq> R^* ==> S^* = R^*"
-  apply (drule rtrancl_mono)
-  apply (drule rtrancl_mono, simp)
+lemma rtrancl_subset': "R \<le> S ==> S \<le> R^** ==> S^** = R^**"
+  apply (drule rtrancl_mono')
+  apply (drule rtrancl_mono', simp)
   done
 
-lemma rtrancl_Un_rtrancl: "(R^* \<union> S^*)^* = (R \<union> S)^*"
-  by (blast intro!: rtrancl_subset intro: r_into_rtrancl rtrancl_mono [THEN subsetD])
+lemmas rtrancl_subset = rtrancl_subset' [to_set]
+
+lemma rtrancl_Un_rtrancl': "(join (R^**) (S^**))^** = (join R S)^**"
+  by (blast intro!: rtrancl_subset' intro: rtrancl_mono' [THEN predicate2D])
 
-lemma rtrancl_reflcl [simp]: "(R^=)^* = R^*"
-  by (blast intro!: rtrancl_subset intro: r_into_rtrancl)
+lemmas rtrancl_Un_rtrancl = rtrancl_Un_rtrancl' [to_set]
+
+lemma rtrancl_reflcl' [simp]: "(R^==)^** = R^**"
+  by (blast intro!: rtrancl_subset')
+
+lemmas rtrancl_reflcl [simp] = rtrancl_reflcl' [to_set]
 
 lemma rtrancl_r_diff_Id: "(r - Id)^* = r^*"
   apply (rule sym)
@@ -157,58 +208,75 @@
   apply (blast intro!: r_into_rtrancl)
   done
 
-theorem rtrancl_converseD:
-  assumes r: "(x, y) \<in> (r^-1)^*"
-  shows "(y, x) \<in> r^*"
+lemma rtrancl_r_diff_Id': "(meet r op ~=)^** = r^**"
+  apply (rule sym)
+  apply (rule rtrancl_subset')
+  apply blast+
+  done
+
+theorem rtrancl_converseD':
+  assumes r: "(r^--1)^** x y"
+  shows "r^** y x"
 proof -
   from r show ?thesis
-    by induct (iprover intro: rtrancl_trans dest!: converseD)+
+    by induct (iprover intro: rtrancl_trans' dest!: conversepD)+
 qed
 
-theorem rtrancl_converseI:
-  assumes r: "(y, x) \<in> r^*"
-  shows "(x, y) \<in> (r^-1)^*"
+lemmas rtrancl_converseD = rtrancl_converseD' [to_set]
+
+theorem rtrancl_converseI':
+  assumes r: "r^** y x"
+  shows "(r^--1)^** x y"
 proof -
   from r show ?thesis
-    by induct (iprover intro: rtrancl_trans converseI)+
+    by induct (iprover intro: rtrancl_trans' conversepI)+
 qed
 
+lemmas rtrancl_converseI = rtrancl_converseI' [to_set]
+
 lemma rtrancl_converse: "(r^-1)^* = (r^*)^-1"
   by (fast dest!: rtrancl_converseD intro!: rtrancl_converseI)
 
 lemma sym_rtrancl: "sym r ==> sym (r^*)"
   by (simp only: sym_conv_converse_eq rtrancl_converse [symmetric])
 
-theorem converse_rtrancl_induct[consumes 1]:
-  assumes major: "(a, b) : r^*"
-    and cases: "P b" "!!y z. [| (y, z) : r; (z, b) : r^*; P z |] ==> P y"
+theorem converse_rtrancl_induct'[consumes 1]:
+  assumes major: "r^** a b"
+    and cases: "P b" "!!y z. [| r y z; r^** z b; P z |] ==> P y"
   shows "P a"
 proof -
-  from rtrancl_converseI [OF major]
+  from rtrancl_converseI' [OF major]
   show ?thesis
-    by induct (iprover intro: cases dest!: converseD rtrancl_converseD)+
+    by induct (iprover intro: cases dest!: conversepD rtrancl_converseD')+
 qed
 
+lemmas converse_rtrancl_induct[consumes 1] = converse_rtrancl_induct' [to_set]
+
+lemmas converse_rtrancl_induct2' =
+  converse_rtrancl_induct'[of _ "(ax,ay)" "(bx,by)", split_rule,
+                 consumes 1, case_names refl step]
+
 lemmas converse_rtrancl_induct2 =
   converse_rtrancl_induct[of "(ax,ay)" "(bx,by)", split_format (complete),
                  consumes 1, case_names refl step]
 
-lemma converse_rtranclE:
-  assumes major: "(x,z):r^*"
+lemma converse_rtranclE':
+  assumes major: "r^** x z"
     and cases: "x=z ==> P"
-      "!!y. [| (x,y):r; (y,z):r^* |] ==> P"
+      "!!y. [| r x y; r^** y z |] ==> P"
   shows P
-  apply (subgoal_tac "x = z | (EX y. (x,y) : r & (y,z) : r^*)")
-   apply (rule_tac [2] major [THEN converse_rtrancl_induct])
+  apply (subgoal_tac "x = z | (EX y. r x y & r^** y z)")
+   apply (rule_tac [2] major [THEN converse_rtrancl_induct'])
     prefer 2 apply iprover
    prefer 2 apply iprover
   apply (erule asm_rl exE disjE conjE cases)+
   done
 
-ML_setup {*
-  bind_thm ("converse_rtranclE2", split_rule
-    (read_instantiate [("x","(xa,xb)"), ("z","(za,zb)")] (thm "converse_rtranclE")));
-*}
+lemmas converse_rtranclE = converse_rtranclE' [to_set]
+
+lemmas converse_rtranclE2' = converse_rtranclE' [of _ "(xa,xb)" "(za,zb)", split_rule]
+
+lemmas converse_rtranclE2 = converse_rtranclE [of "(xa,xb)" "(za,zb)", split_rule]
 
 lemma r_comp_rtrancl_eq: "r O r^* = r^* O r"
   by (blast elim: rtranclE converse_rtranclE
@@ -220,8 +288,14 @@
 
 subsection {* Transitive closure *}
 
+lemma trancl_set_eq [pred_set_conv]: "(member2 r)^++ = member2 (r^+)"
+  by (simp add: trancl_set_def)
+
+lemmas r_into_trancl [intro, Pure.intro] = r_into_trancl [to_set]
+lemmas trancl_into_trancl [Pure.intro] = trancl_into_trancl [to_set]
+
 lemma trancl_mono: "!!p. p \<in> r^+ ==> r \<subseteq> s ==> p \<in> s^+"
-  apply (simp only: split_tupled_all)
+  apply (simp add: split_tupled_all trancl_set_def)
   apply (erule trancl.induct)
   apply (iprover dest: subsetD)+
   done
@@ -233,24 +307,30 @@
   \medskip Conversions between @{text trancl} and @{text rtrancl}.
 *}
 
-lemma trancl_into_rtrancl: "(a, b) \<in> r^+ ==> (a, b) \<in> r^*"
+lemma trancl_into_rtrancl': "r^++ a b ==> r^** a b"
   by (erule trancl.induct) iprover+
 
-lemma rtrancl_into_trancl1: assumes r: "(a, b) \<in> r^*"
-  shows "!!c. (b, c) \<in> r ==> (a, c) \<in> r^+" using r
+lemmas trancl_into_rtrancl = trancl_into_rtrancl' [to_set]
+
+lemma rtrancl_into_trancl1': assumes r: "r^** a b"
+  shows "!!c. r b c ==> r^++ a c" using r
   by induct iprover+
 
-lemma rtrancl_into_trancl2: "[| (a,b) : r;  (b,c) : r^* |]   ==>  (a,c) : r^+"
+lemmas rtrancl_into_trancl1 = rtrancl_into_trancl1' [to_set]
+
+lemma rtrancl_into_trancl2': "[| r a b; r^** b c |] ==> r^++ a c"
   -- {* intro rule from @{text r} and @{text rtrancl} *}
-  apply (erule rtranclE, iprover)
-  apply (rule rtrancl_trans [THEN rtrancl_into_trancl1])
-   apply (assumption | rule r_into_rtrancl)+
+  apply (erule rtrancl.cases, iprover)
+  apply (rule rtrancl_trans' [THEN rtrancl_into_trancl1'])
+   apply (simp | rule r_into_rtrancl')+
   done
 
-lemma trancl_induct [consumes 1, induct set: trancl]:
-  assumes a: "(a,b) : r^+"
-  and cases: "!!y. (a, y) : r ==> P y"
-    "!!y z. (a,y) : r^+ ==> (y, z) : r ==> P y ==> P z"
+lemmas rtrancl_into_trancl2 = rtrancl_into_trancl2' [to_set]
+
+lemma trancl_induct' [consumes 1, induct set: trancl]:
+  assumes a: "r^++ a b"
+  and cases: "!!y. r a y ==> P y"
+    "!!y z. r^++ a y ==> r y z ==> P y ==> P z"
   shows "P b"
   -- {* Nice induction rule for @{text trancl} *}
 proof -
@@ -259,19 +339,32 @@
   thus ?thesis by iprover
 qed
 
+lemmas trancl_induct [consumes 1, induct set: trancl_set] = trancl_induct' [to_set]
+
+lemmas trancl_induct2' =
+  trancl_induct'[of _ "(ax,ay)" "(bx,by)", split_rule,
+                 consumes 1, case_names base step]
+
 lemmas trancl_induct2 =
   trancl_induct[of "(ax,ay)" "(bx,by)", split_format (complete),
                  consumes 1, case_names base step]
 
-lemma trancl_trans_induct:
-  assumes major: "(x,y) : r^+"
-    and cases: "!!x y. (x,y) : r ==> P x y"
-      "!!x y z. [| (x,y) : r^+; P x y; (y,z) : r^+; P y z |] ==> P x z"
+lemma trancl_trans_induct':
+  assumes major: "r^++ x y"
+    and cases: "!!x y. r x y ==> P x y"
+      "!!x y z. [| r^++ x y; P x y; r^++ y z; P y z |] ==> P x z"
   shows "P x y"
   -- {* Another induction rule for trancl, incorporating transitivity *}
-  by (iprover intro: r_into_trancl major [THEN trancl_induct] cases)
+  by (iprover intro: major [THEN trancl_induct'] cases)
+
+lemmas trancl_trans_induct = trancl_trans_induct' [to_set]
 
-inductive_cases tranclE: "(a, b) : r^+"
+lemma tranclE:
+  assumes H: "(a, b) : r^+"
+  and cases: "(a, b) : r ==> P" "\<And>c. (a, c) : r^+ ==> (c, b) : r ==> P"
+  shows P
+  using H [simplified trancl_set_def, simplified]
+  by cases (auto intro: cases [simplified trancl_set_def, simplified])
 
 lemma trancl_Int_subset: "[| r \<subseteq> s; r O (r^+ \<inter> s) \<subseteq> s|] ==> r^+ \<subseteq> s"
   apply (rule subsetI)
@@ -293,6 +386,12 @@
 
 lemmas trancl_trans = trans_trancl [THEN transD, standard]
 
+lemma trancl_trans':
+  assumes xy: "r^++ x y"
+  and yz: "r^++ y z"
+  shows "r^++ x z" using yz xy
+  by induct iprover+
+
 lemma trancl_id[simp]: "trans r \<Longrightarrow> r^+ = r"
 apply(auto)
 apply(erule trancl_induct)
@@ -301,12 +400,16 @@
 apply(blast)
 done
 
-lemma rtrancl_trancl_trancl: assumes r: "(x, y) \<in> r^*"
-  shows "!!z. (y, z) \<in> r^+ ==> (x, z) \<in> r^+" using r
-  by induct (iprover intro: trancl_trans)+
+lemma rtrancl_trancl_trancl': assumes r: "r^** x y"
+  shows "!!z. r^++ y z ==> r^++ x z" using r
+  by induct (iprover intro: trancl_trans')+
 
-lemma trancl_into_trancl2: "(a, b) \<in> r ==> (b, c) \<in> r^+ ==> (a, c) \<in> r^+"
-  by (erule transD [OF trans_trancl r_into_trancl])
+lemmas rtrancl_trancl_trancl = rtrancl_trancl_trancl' [to_set]
+
+lemma trancl_into_trancl2': "r a b ==> r^++ b c ==> r^++ a c"
+  by (erule trancl_trans' [OF trancl.r_into_trancl])
+
+lemmas trancl_into_trancl2 = trancl_into_trancl2' [to_set]
 
 lemma trancl_insert:
   "(insert (y, x) r)^+ = r^+ \<union> {(a, b). (a, y) \<in> r^* \<and> (x, b) \<in> r^*}"
@@ -321,41 +424,51 @@
     [THEN [2] rev_subsetD] rtrancl_trancl_trancl rtrancl_into_trancl2)
   done
 
-lemma trancl_converseI: "(x, y) \<in> (r^+)^-1 ==> (x, y) \<in> (r^-1)^+"
-  apply (drule converseD)
-  apply (erule trancl.induct)
-  apply (iprover intro: converseI trancl_trans)+
+lemma trancl_converseI': "(r^++)^--1 x y ==> (r^--1)^++ x y"
+  apply (drule conversepD)
+  apply (erule trancl_induct')
+  apply (iprover intro: conversepI trancl_trans')+
   done
 
-lemma trancl_converseD: "(x, y) \<in> (r^-1)^+ ==> (x, y) \<in> (r^+)^-1"
-  apply (rule converseI)
-  apply (erule trancl.induct)
-  apply (iprover dest: converseD intro: trancl_trans)+
+lemmas trancl_converseI = trancl_converseI' [to_set]
+
+lemma trancl_converseD': "(r^--1)^++ x y ==> (r^++)^--1 x y"
+  apply (rule conversepI)
+  apply (erule trancl_induct')
+  apply (iprover dest: conversepD intro: trancl_trans')+
   done
 
-lemma trancl_converse: "(r^-1)^+ = (r^+)^-1"
-  by (fastsimp simp add: split_tupled_all
-    intro!: trancl_converseI trancl_converseD)
+lemmas trancl_converseD = trancl_converseD' [to_set]
+
+lemma trancl_converse': "(r^--1)^++ = (r^++)^--1"
+  by (fastsimp simp add: expand_fun_eq
+    intro!: trancl_converseI' dest!: trancl_converseD')
+
+lemmas trancl_converse = trancl_converse' [to_set]
 
 lemma sym_trancl: "sym r ==> sym (r^+)"
   by (simp only: sym_conv_converse_eq trancl_converse [symmetric])
 
-lemma converse_trancl_induct:
-  assumes major: "(a,b) : r^+"
-    and cases: "!!y. (y,b) : r ==> P(y)"
-      "!!y z.[| (y,z) : r;  (z,b) : r^+;  P(z) |] ==> P(y)"
+lemma converse_trancl_induct':
+  assumes major: "r^++ a b"
+    and cases: "!!y. r y b ==> P(y)"
+      "!!y z.[| r y z;  r^++ z b;  P(z) |] ==> P(y)"
   shows "P a"
-  apply (rule major [THEN converseI, THEN trancl_converseI [THEN trancl_induct]])
+  apply (rule trancl_induct' [OF trancl_converseI', OF conversepI, OF major])
    apply (rule cases)
-   apply (erule converseD)
-  apply (blast intro: prems dest!: trancl_converseD)
+   apply (erule conversepD)
+  apply (blast intro: prems dest!: trancl_converseD' conversepD)
   done
 
-lemma tranclD: "(x, y) \<in> R^+ ==> EX z. (x, z) \<in> R \<and> (z, y) \<in> R^*"
-  apply (erule converse_trancl_induct, auto)
-  apply (blast intro: rtrancl_trans)
+lemmas converse_trancl_induct = converse_trancl_induct' [to_set]
+
+lemma tranclD': "R^++ x y ==> EX z. R x z \<and> R^** z y"
+  apply (erule converse_trancl_induct', auto)
+  apply (blast intro: rtrancl_trans')
   done
 
+lemmas tranclD = tranclD' [to_set]
+
 lemma irrefl_tranclI: "r^-1 \<inter> r^* = {} ==> (x, x) \<notin> r^+"
   by (blast elim: tranclE dest: trancl_into_rtrancl)
 
@@ -373,12 +486,14 @@
   apply (blast dest!: trancl_into_rtrancl trancl_subset_Sigma_aux)+
   done
 
-lemma reflcl_trancl [simp]: "(r^+)^= = r^*"
-  apply safe
-   apply (erule trancl_into_rtrancl)
-  apply (blast elim: rtranclE dest: rtrancl_into_trancl1)
+lemma reflcl_trancl' [simp]: "(r^++)^== = r^**"
+  apply (safe intro!: order_antisym)
+   apply (erule trancl_into_rtrancl')
+  apply (blast elim: rtrancl.cases dest: rtrancl_into_trancl1')
   done
 
+lemmas reflcl_trancl [simp] = reflcl_trancl' [to_set]
+
 lemma trancl_reflcl [simp]: "(r^=)^+ = r^*"
   apply safe
    apply (drule trancl_into_rtrancl, simp)
@@ -394,8 +509,10 @@
 lemma rtrancl_empty [simp]: "{}^* = Id"
   by (rule subst [OF reflcl_trancl]) simp
 
-lemma rtranclD: "(a, b) \<in> R^* ==> a = b \<or> a \<noteq> b \<and> (a, b) \<in> R^+"
-  by (force simp add: reflcl_trancl [symmetric] simp del: reflcl_trancl)
+lemma rtranclD': "R^** a b ==> a = b \<or> a \<noteq> b \<and> R^++ a b"
+  by (force simp add: reflcl_trancl' [symmetric] simp del: reflcl_trancl')
+
+lemmas rtranclD = rtranclD' [to_set]
 
 lemma rtrancl_eq_or_trancl:
   "(x,y) \<in> R\<^sup>* = (x=y \<or> x\<noteq>y \<and> (x,y) \<in> R\<^sup>+)"
@@ -450,24 +567,32 @@
   apply (fast intro: r_r_into_trancl trancl_trans)
   done
 
-lemma trancl_rtrancl_trancl:
-    "(a, b) \<in> r\<^sup>+ ==> (b, c) \<in> r\<^sup>* ==> (a, c) \<in> r\<^sup>+"
-  apply (drule tranclD)
+lemma trancl_rtrancl_trancl':
+    "r\<^sup>+\<^sup>+ a b ==> r\<^sup>*\<^sup>* b c ==> r\<^sup>+\<^sup>+ a c"
+  apply (drule tranclD')
   apply (erule exE, erule conjE)
-  apply (drule rtrancl_trans, assumption)
-  apply (drule rtrancl_into_trancl2, assumption, assumption)
+  apply (drule rtrancl_trans', assumption)
+  apply (drule rtrancl_into_trancl2', assumption, assumption)
   done
 
+lemmas trancl_rtrancl_trancl = trancl_rtrancl_trancl' [to_set]
+
 lemmas transitive_closure_trans [trans] =
   r_r_into_trancl trancl_trans rtrancl_trans
   trancl_into_trancl trancl_into_trancl2
   rtrancl_into_rtrancl converse_rtrancl_into_rtrancl
   rtrancl_trancl_trancl trancl_rtrancl_trancl
 
+lemmas transitive_closure_trans' [trans] =
+  trancl_trans' rtrancl_trans'
+  trancl.trancl_into_trancl trancl_into_trancl2'
+  rtrancl.rtrancl_into_rtrancl converse_rtrancl_into_rtrancl'
+  rtrancl_trancl_trancl' trancl_rtrancl_trancl'
+
 declare trancl_into_rtrancl [elim]
 
-declare rtranclE [cases set: rtrancl]
-declare tranclE [cases set: trancl]
+declare rtranclE [cases set: rtrancl_set]
+declare tranclE [cases set: trancl_set]
 
 
 
@@ -490,8 +615,8 @@
 
   fun decomp (Trueprop $ t) =
     let fun dec (Const ("op :", _) $ (Const ("Pair", _) $ a $ b) $ rel ) =
-        let fun decr (Const ("Transitive_Closure.rtrancl", _ ) $ r) = (r,"r*")
-              | decr (Const ("Transitive_Closure.trancl", _ ) $ r)  = (r,"r+")
+        let fun decr (Const ("Transitive_Closure.rtrancl_set", _ ) $ r) = (r,"r*")
+              | decr (Const ("Transitive_Closure.trancl_set", _ ) $ r)  = (r,"r+")
               | decr r = (r,"r");
             val (rel,r) = decr rel;
         in SOME (a,b,rel,r) end
@@ -500,9 +625,34 @@
 
   end);
 
+structure Tranclp_Tac = Trancl_Tac_Fun (
+  struct
+    val r_into_trancl = thm "trancl.r_into_trancl";
+    val trancl_trans  = thm "trancl_trans'";
+    val rtrancl_refl = thm "rtrancl.rtrancl_refl";
+    val r_into_rtrancl = thm "r_into_rtrancl'";
+    val trancl_into_rtrancl = thm "trancl_into_rtrancl'";
+    val rtrancl_trancl_trancl = thm "rtrancl_trancl_trancl'";
+    val trancl_rtrancl_trancl = thm "trancl_rtrancl_trancl'";
+    val rtrancl_trans = thm "rtrancl_trans'";
+
+  fun decomp (Trueprop $ t) =
+    let fun dec (rel $ a $ b) =
+        let fun decr (Const ("Transitive_Closure.rtrancl", _ ) $ r) = (r,"r*")
+              | decr (Const ("Transitive_Closure.trancl", _ ) $ r)  = (r,"r+")
+              | decr r = (r,"r");
+            val (rel,r) = decr rel;
+        in SOME (a, b, Envir.beta_eta_contract rel, r) end
+      | dec _ =  NONE
+    in dec t end;
+
+  end);
+
 change_simpset (fn ss => ss
   addSolver (mk_solver "Trancl" (fn _ => Trancl_Tac.trancl_tac))
-  addSolver (mk_solver "Rtrancl" (fn _ => Trancl_Tac.rtrancl_tac)));
+  addSolver (mk_solver "Rtrancl" (fn _ => Trancl_Tac.rtrancl_tac))
+  addSolver (mk_solver "Tranclp" (fn _ => Tranclp_Tac.trancl_tac))
+  addSolver (mk_solver "Rtranclp" (fn _ => Tranclp_Tac.rtrancl_tac)));
 
 *}
 
@@ -514,5 +664,11 @@
 method_setup rtrancl =
   {* Method.no_args (Method.SIMPLE_METHOD' Trancl_Tac.rtrancl_tac) *}
   {* simple transitivity reasoner *}
+method_setup tranclp =
+  {* Method.no_args (Method.SIMPLE_METHOD' Tranclp_Tac.trancl_tac) *}
+  {* simple transitivity reasoner (predicate version) *}
+method_setup rtranclp =
+  {* Method.no_args (Method.SIMPLE_METHOD' Tranclp_Tac.rtrancl_tac) *}
+  {* simple transitivity reasoner (predicate version) *}
 
 end