10213
|
1 |
(* Title: HOL/Relation_Power.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Tobias Nipkow
|
|
4 |
Copyright 1996 TU Muenchen
|
15410
|
5 |
*)
|
11306
|
6 |
|
15410
|
7 |
header{*Powers of Relations and Functions*}
|
10213
|
8 |
|
15131
|
9 |
theory Relation_Power
|
15140
|
10 |
imports Nat
|
15131
|
11 |
begin
|
10213
|
12 |
|
|
13 |
instance
|
15410
|
14 |
set :: (type) power ..
|
|
15 |
--{* only type @{typ "('a * 'a) set"} should be in class @{text power}!*}
|
10213
|
16 |
|
15410
|
17 |
(*R^n = R O ... O R, the n-fold composition of R*)
|
10213
|
18 |
primrec (relpow)
|
|
19 |
"R^0 = Id"
|
|
20 |
"R^(Suc n) = R O (R^n)"
|
|
21 |
|
11305
|
22 |
|
11306
|
23 |
instance
|
15410
|
24 |
fun :: (type, type) power ..
|
|
25 |
--{* only type @{typ "'a => 'a"} should be in class @{text power}!*}
|
11305
|
26 |
|
15410
|
27 |
(*f^n = f o ... o f, the n-fold composition of f*)
|
11305
|
28 |
primrec (funpow)
|
|
29 |
"f^0 = id"
|
|
30 |
"f^(Suc n) = f o (f^n)"
|
|
31 |
|
15410
|
32 |
text{*WARNING: due to the limits of Isabelle's type classes, exponentiation on
|
|
33 |
functions and relations has too general a domain, namely @{typ "('a * 'b)set"}
|
|
34 |
and @{typ "'a => 'b"}. Explicit type constraints may therefore be necessary.
|
|
35 |
For example, @{term "range(f^n) = A"} and @{term "Range(R^n) = B"} need
|
|
36 |
constraints.*}
|
|
37 |
|
15112
|
38 |
lemma funpow_add: "f ^ (m+n) = f^m o f^n"
|
|
39 |
by(induct m) simp_all
|
|
40 |
|
15410
|
41 |
lemma rel_pow_1: "!!R:: ('a*'a)set. R^1 = R"
|
|
42 |
by simp
|
|
43 |
declare rel_pow_1 [simp]
|
|
44 |
|
|
45 |
lemma rel_pow_0_I: "(x,x) : R^0"
|
|
46 |
by simp
|
|
47 |
|
|
48 |
lemma rel_pow_Suc_I: "[| (x,y) : R^n; (y,z):R |] ==> (x,z):R^(Suc n)"
|
|
49 |
apply (auto );
|
|
50 |
done
|
|
51 |
|
|
52 |
lemma rel_pow_Suc_I2 [rule_format]:
|
|
53 |
"\<forall>z. (x,y) : R --> (y,z):R^n --> (x,z):R^(Suc n)"
|
|
54 |
apply (induct_tac "n", simp_all)
|
|
55 |
apply blast
|
|
56 |
done
|
|
57 |
|
|
58 |
lemma rel_pow_0_E: "[| (x,y) : R^0; x=y ==> P |] ==> P"
|
|
59 |
by simp
|
|
60 |
|
|
61 |
lemma rel_pow_Suc_E:
|
|
62 |
"[| (x,z) : R^(Suc n); !!y. [| (x,y) : R^n; (y,z) : R |] ==> P |] ==> P"
|
|
63 |
by auto
|
|
64 |
|
|
65 |
lemma rel_pow_E:
|
|
66 |
"[| (x,z) : R^n; [| n=0; x = z |] ==> P;
|
|
67 |
!!y m. [| n = Suc m; (x,y) : R^m; (y,z) : R |] ==> P
|
|
68 |
|] ==> P"
|
|
69 |
by (case_tac "n", auto)
|
|
70 |
|
|
71 |
lemma rel_pow_Suc_D2 [rule_format]:
|
|
72 |
"\<forall>x z. (x,z):R^(Suc n) --> (\<exists>y. (x,y):R & (y,z):R^n)"
|
|
73 |
apply (induct_tac "n")
|
|
74 |
apply (blast intro: rel_pow_0_I elim: rel_pow_0_E rel_pow_Suc_E)
|
|
75 |
apply (blast intro: rel_pow_Suc_I elim: rel_pow_0_E rel_pow_Suc_E)
|
|
76 |
done
|
|
77 |
|
|
78 |
|
|
79 |
lemma rel_pow_Suc_D2':
|
|
80 |
"\<forall>x y z. (x,y) : R^n & (y,z) : R --> (\<exists>w. (x,w) : R & (w,z) : R^n)"
|
|
81 |
by (induct_tac "n", simp_all, blast)
|
|
82 |
|
|
83 |
lemma rel_pow_E2:
|
|
84 |
"[| (x,z) : R^n; [| n=0; x = z |] ==> P;
|
|
85 |
!!y m. [| n = Suc m; (x,y) : R; (y,z) : R^m |] ==> P
|
|
86 |
|] ==> P"
|
|
87 |
apply (case_tac "n", simp)
|
|
88 |
apply (cut_tac n=nat and R=R in rel_pow_Suc_D2', simp, blast)
|
|
89 |
done
|
|
90 |
|
|
91 |
lemma rtrancl_imp_UN_rel_pow: "!!p. p:R^* ==> p : (UN n. R^n)"
|
|
92 |
apply (simp only: split_tupled_all)
|
|
93 |
apply (erule rtrancl_induct)
|
|
94 |
apply (blast intro: rel_pow_0_I rel_pow_Suc_I)+
|
|
95 |
done
|
|
96 |
|
|
97 |
lemma rel_pow_imp_rtrancl: "!!p. p:R^n ==> p:R^*"
|
|
98 |
apply (simp only: split_tupled_all)
|
|
99 |
apply (induct "n")
|
|
100 |
apply (blast intro: rtrancl_refl elim: rel_pow_0_E)
|
|
101 |
apply (blast elim: rel_pow_Suc_E intro: rtrancl_into_rtrancl)
|
|
102 |
done
|
|
103 |
|
|
104 |
lemma rtrancl_is_UN_rel_pow: "R^* = (UN n. R^n)"
|
|
105 |
by (blast intro: rtrancl_imp_UN_rel_pow rel_pow_imp_rtrancl)
|
|
106 |
|
|
107 |
|
|
108 |
lemma single_valued_rel_pow [rule_format]:
|
|
109 |
"!!r::('a * 'a)set. single_valued r ==> single_valued (r^n)"
|
|
110 |
apply (rule single_valuedI)
|
|
111 |
apply (induct_tac "n", simp)
|
|
112 |
apply (fast dest: single_valuedD elim: rel_pow_Suc_E)
|
|
113 |
done
|
|
114 |
|
|
115 |
ML
|
|
116 |
{*
|
|
117 |
val funpow_add = thm "funpow_add";
|
|
118 |
val rel_pow_1 = thm "rel_pow_1";
|
|
119 |
val rel_pow_0_I = thm "rel_pow_0_I";
|
|
120 |
val rel_pow_Suc_I = thm "rel_pow_Suc_I";
|
|
121 |
val rel_pow_Suc_I2 = thm "rel_pow_Suc_I2";
|
|
122 |
val rel_pow_0_E = thm "rel_pow_0_E";
|
|
123 |
val rel_pow_Suc_E = thm "rel_pow_Suc_E";
|
|
124 |
val rel_pow_E = thm "rel_pow_E";
|
|
125 |
val rel_pow_Suc_D2 = thm "rel_pow_Suc_D2";
|
|
126 |
val rel_pow_Suc_D2 = thm "rel_pow_Suc_D2";
|
|
127 |
val rel_pow_E2 = thm "rel_pow_E2";
|
|
128 |
val rtrancl_imp_UN_rel_pow = thm "rtrancl_imp_UN_rel_pow";
|
|
129 |
val rel_pow_imp_rtrancl = thm "rel_pow_imp_rtrancl";
|
|
130 |
val rtrancl_is_UN_rel_pow = thm "rtrancl_is_UN_rel_pow";
|
|
131 |
val single_valued_rel_pow = thm "single_valued_rel_pow";
|
|
132 |
*}
|
|
133 |
|
10213
|
134 |
end
|