# HG changeset patch # User Christian Sternagel # Date 1334589771 -7200 # Node ID 2631a12fb2d1846d38867ac0907a37a55d8617a2 # Parent f4348634595be209a81b00f86d5fd2a73da15249 duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems") diff -r f4348634595b -r 2631a12fb2d1 src/HOL/Transitive_Closure.thy --- a/src/HOL/Transitive_Closure.thy Mon Apr 16 15:09:47 2012 +0200 +++ b/src/HOL/Transitive_Closure.thy Mon Apr 16 17:22:51 2012 +0200 @@ -733,44 +733,84 @@ definition relpow :: "nat \ ('a \ 'a) set \ ('a \ 'a) set" where relpow_code_def [code_abbrev]: "relpow = compow" +definition relpowp :: "nat \ ('a \ 'a \ bool) \ ('a \ 'a \ bool)" where + relpowp_code_def [code_abbrev]: "relpowp = compow" + lemma [code]: "relpow (Suc n) R = (relpow n R) O R" "relpow 0 R = Id" by (simp_all add: relpow_code_def) +lemma [code]: + "relpowp (Suc n) R = (R ^^ n) OO R" + "relpowp 0 R = HOL.eq" + by (simp_all add: relpowp_code_def) + hide_const (open) relpow +hide_const (open) relpowp lemma relpow_1 [simp]: fixes R :: "('a \ 'a) set" shows "R ^^ 1 = R" by simp +lemma relpowp_1 [simp]: + fixes P :: "'a \ 'a \ bool" + shows "P ^^ 1 = P" + by (fact relpow_1 [to_pred]) + lemma relpow_0_I: "(x, x) \ R ^^ 0" by simp +lemma relpowp_0_I: + "(P ^^ 0) x x" + by (fact relpow_0_I [to_pred]) + lemma relpow_Suc_I: "(x, y) \ R ^^ n \ (y, z) \ R \ (x, z) \ R ^^ Suc n" by auto +lemma relpowp_Suc_I: + "(P ^^ n) x y \ P y z \ (P ^^ Suc n) x z" + by (fact relpow_Suc_I [to_pred]) + lemma relpow_Suc_I2: "(x, y) \ R \ (y, z) \ R ^^ n \ (x, z) \ R ^^ Suc n" by (induct n arbitrary: z) (simp, fastforce) +lemma relpowp_Suc_I2: + "P x y \ (P ^^ n) y z \ (P ^^ Suc n) x z" + by (fact relpow_Suc_I2 [to_pred]) + lemma relpow_0_E: "(x, y) \ R ^^ 0 \ (x = y \ P) \ P" by simp +lemma relpowp_0_E: + "(P ^^ 0) x y \ (x = y \ Q) \ Q" + by (fact relpow_0_E [to_pred]) + lemma relpow_Suc_E: "(x, z) \ R ^^ Suc n \ (\y. (x, y) \ R ^^ n \ (y, z) \ R \ P) \ P" by auto +lemma relpowp_Suc_E: + "(P ^^ Suc n) x z \ (\y. (P ^^ n) x y \ P y z \ Q) \ Q" + by (fact relpow_Suc_E [to_pred]) + lemma relpow_E: "(x, z) \ R ^^ n \ (n = 0 \ x = z \ P) \ (\y m. n = Suc m \ (x, y) \ R ^^ m \ (y, z) \ R \ P) \ P" by (cases n) auto +lemma relpowp_E: + "(P ^^ n) x z \ (n = 0 \ x = z \ Q) + \ (\y m. n = Suc m \ (P ^^ m) x y \ P y z \ Q) + \ Q" + by (fact relpow_E [to_pred]) + lemma relpow_Suc_D2: "(x, z) \ R ^^ Suc n \ (\y. (x, y) \ R \ (y, z) \ R ^^ n)" apply (induct n arbitrary: x z) @@ -778,14 +818,26 @@ apply (blast intro: relpow_Suc_I elim: relpow_0_E relpow_Suc_E) done +lemma relpowp_Suc_D2: + "(P ^^ Suc n) x z \ \y. P x y \ (P ^^ n) y z" + by (fact relpow_Suc_D2 [to_pred]) + lemma relpow_Suc_E2: "(x, z) \ R ^^ Suc n \ (\y. (x, y) \ R \ (y, z) \ R ^^ n \ P) \ P" by (blast dest: relpow_Suc_D2) +lemma relpowp_Suc_E2: + "(P ^^ Suc n) x z \ (\y. P x y \ (P ^^ n) y z \ Q) \ Q" + by (fact relpow_Suc_E2 [to_pred]) + lemma relpow_Suc_D2': "\x y z. (x, y) \ R ^^ n \ (y, z) \ R \ (\w. (x, w) \ R \ (w, z) \ R ^^ n)" by (induct n) (simp_all, blast) +lemma relpowp_Suc_D2': + "\x y z. (P ^^ n) x y \ P y z \ (\w. P x w \ (P ^^ n) w z)" + by (fact relpow_Suc_D2' [to_pred]) + lemma relpow_E2: "(x, z) \ R ^^ n \ (n = 0 \ x = z \ P) \ (\y m. n = Suc m \ (x, y) \ R \ (y, z) \ R ^^ m \ P) @@ -794,16 +846,32 @@ apply (cut_tac n=nat and R=R in relpow_Suc_D2', simp, blast) done +lemma relpowp_E2: + "(P ^^ n) x z \ (n = 0 \ x = z \ Q) + \ (\y m. n = Suc m \ P x y \ (P ^^ m) y z \ Q) + \ Q" + by (fact relpow_E2 [to_pred]) + lemma relpow_add: "R ^^ (m+n) = R^^m O R^^n" by (induct n) auto +lemma relpowp_add: "P ^^ (m + n) = P ^^ m OO P ^^ n" + by (fact relpow_add [to_pred]) + lemma relpow_commute: "R O R ^^ n = R ^^ n O R" by (induct n) (simp, simp add: O_assoc [symmetric]) +lemma relpowp_commute: "P OO P ^^ n = P ^^ n OO P" + by (fact relpow_commute [to_pred]) + lemma relpow_empty: "0 < n \ ({} :: ('a \ 'a) set) ^^ n = {}" by (cases n) auto +lemma relpowp_bot: + "0 < n \ (\ :: 'a \ 'a \ bool) ^^ n = \" + by (fact relpow_empty [to_pred]) + lemma rtrancl_imp_UN_relpow: assumes "p \ R^*" shows "p \ (\n. R ^^ n)" @@ -818,6 +886,11 @@ with Pair show ?thesis by simp qed +lemma rtranclp_imp_Sup_relpowp: + assumes "(P^**) x y" + shows "(\n. P ^^ n) x y" + using assms and rtrancl_imp_UN_relpow [to_pred] by blast + lemma relpow_imp_rtrancl: assumes "p \ R ^^ n" shows "p \ R^*" @@ -833,14 +906,27 @@ with Pair show ?thesis by simp qed +lemma relpowp_imp_rtranclp: + assumes "(P ^^ n) x y" + shows "(P^**) x y" + using assms and relpow_imp_rtrancl [to_pred] by blast + lemma rtrancl_is_UN_relpow: "R^* = (\n. R ^^ n)" by (blast intro: rtrancl_imp_UN_relpow relpow_imp_rtrancl) +lemma rtranclp_is_Sup_relpowp: + "P^** = (\n. P ^^ n)" + using rtrancl_is_UN_relpow [to_pred, of P] by auto + lemma rtrancl_power: "p \ R^* \ (\n. p \ R ^^ n)" by (simp add: rtrancl_is_UN_relpow) +lemma rtranclp_power: + "(P^**) x y \ (\n. (P ^^ n) x y)" + by (simp add: rtranclp_is_Sup_relpowp) + lemma trancl_power: "p \ R^+ \ (\n > 0. p \ R ^^ n)" apply (cases p) @@ -858,10 +944,18 @@ apply (drule rtrancl_into_trancl1) apply auto done +lemma tranclp_power: + "(P^++) x y \ (\n > 0. (P ^^ n) x y)" + using trancl_power [to_pred, of P "(x, y)"] by simp + lemma rtrancl_imp_relpow: "p \ R^* \ \n. p \ R ^^ n" by (auto dest: rtrancl_imp_UN_relpow) +lemma rtranclp_imp_relpowp: + "(P^**) x y \ \n. (P ^^ n) x y" + by (auto dest: rtranclp_imp_Sup_relpowp) + text{* By Sternagel/Thiemann: *} lemma relpow_fun_conv: "((a,b) \ R ^^ n) = (\f. f 0 = a \ f n = b \ (\i R))" @@ -887,6 +981,10 @@ qed qed +lemma relpowp_fun_conv: + "(P ^^ n) x y \ (\f. f 0 = x \ f n = y \ (\i0" shows "R^^k \ (UN n:{n. 0 ?r")