author | haftmann |
Thu, 13 Oct 2011 23:02:59 +0200 | |
changeset 45139 | bdcaa3f3a2f4 |
parent 45137 | 6e422d180de8 |
child 45967 | 76cf71ed15c7 |
permissions | -rw-r--r-- |
10358 | 1 |
(* Title: HOL/Relation.thy |
1983 | 2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
3 |
Copyright 1996 University of Cambridge |
|
1128
64b30e3cc6d4
Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff
changeset
|
4 |
*) |
64b30e3cc6d4
Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff
changeset
|
5 |
|
12905 | 6 |
header {* Relations *} |
7 |
||
15131 | 8 |
theory Relation |
32850 | 9 |
imports Datatype Finite_Set |
15131 | 10 |
begin |
5978
fa2c2dd74f8c
moved diag (diagonal relation) from Univ to Relation
paulson
parents:
5608
diff
changeset
|
11 |
|
12913 | 12 |
subsection {* Definitions *} |
13 |
||
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19363
diff
changeset
|
14 |
definition |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
15 |
converse :: "('a * 'b) set => ('b * 'a) set" |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
16 |
("(_^-1)" [1000] 999) where |
45137 | 17 |
"r^-1 = {(y, x). (x, y) : r}" |
7912 | 18 |
|
21210 | 19 |
notation (xsymbols) |
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19363
diff
changeset
|
20 |
converse ("(_\<inverse>)" [1000] 999) |
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19363
diff
changeset
|
21 |
|
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19363
diff
changeset
|
22 |
definition |
32235
8f9b8d14fc9f
"more standard" argument order of relation composition (op O)
krauss
parents:
31011
diff
changeset
|
23 |
rel_comp :: "[('a * 'b) set, ('b * 'c) set] => ('a * 'c) set" |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
24 |
(infixr "O" 75) where |
45137 | 25 |
"r O s = {(x,z). EX y. (x, y) : r & (y, z) : s}" |
12913 | 26 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
27 |
definition |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
28 |
Image :: "[('a * 'b) set, 'a set] => 'b set" |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
29 |
(infixl "``" 90) where |
45137 | 30 |
"r `` s = {y. EX x:s. (x,y):r}" |
7912 | 31 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
32 |
definition |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
33 |
Id :: "('a * 'a) set" where -- {* the identity relation *} |
45137 | 34 |
"Id = {p. EX x. p = (x,x)}" |
7912 | 35 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
36 |
definition |
30198 | 37 |
Id_on :: "'a set => ('a * 'a) set" where -- {* diagonal: identity over a set *} |
45137 | 38 |
"Id_on A = (\<Union>x\<in>A. {(x,x)})" |
12913 | 39 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
40 |
definition |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
41 |
Domain :: "('a * 'b) set => 'a set" where |
45137 | 42 |
"Domain r = {x. EX y. (x,y):r}" |
5978
fa2c2dd74f8c
moved diag (diagonal relation) from Univ to Relation
paulson
parents:
5608
diff
changeset
|
43 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
44 |
definition |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
45 |
Range :: "('a * 'b) set => 'b set" where |
45137 | 46 |
"Range r = Domain(r^-1)" |
5978
fa2c2dd74f8c
moved diag (diagonal relation) from Univ to Relation
paulson
parents:
5608
diff
changeset
|
47 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
48 |
definition |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
49 |
Field :: "('a * 'a) set => 'a set" where |
45137 | 50 |
"Field r = Domain r \<union> Range r" |
10786 | 51 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
52 |
definition |
30198 | 53 |
refl_on :: "['a set, ('a * 'a) set] => bool" where -- {* reflexivity over a set *} |
45137 | 54 |
"refl_on A r \<longleftrightarrow> r \<subseteq> A \<times> A & (ALL x: A. (x,x) : r)" |
6806
43c081a0858d
new preficates refl, sym [from Integ/Equiv], antisym
paulson
parents:
5978
diff
changeset
|
55 |
|
26297 | 56 |
abbreviation |
30198 | 57 |
refl :: "('a * 'a) set => bool" where -- {* reflexivity over a type *} |
45137 | 58 |
"refl \<equiv> refl_on UNIV" |
26297 | 59 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
60 |
definition |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
61 |
sym :: "('a * 'a) set => bool" where -- {* symmetry predicate *} |
45137 | 62 |
"sym r \<longleftrightarrow> (ALL x y. (x,y): r --> (y,x): r)" |
6806
43c081a0858d
new preficates refl, sym [from Integ/Equiv], antisym
paulson
parents:
5978
diff
changeset
|
63 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
64 |
definition |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
65 |
antisym :: "('a * 'a) set => bool" where -- {* antisymmetry predicate *} |
45137 | 66 |
"antisym r \<longleftrightarrow> (ALL x y. (x,y):r --> (y,x):r --> x=y)" |
6806
43c081a0858d
new preficates refl, sym [from Integ/Equiv], antisym
paulson
parents:
5978
diff
changeset
|
67 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
68 |
definition |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
69 |
trans :: "('a * 'a) set => bool" where -- {* transitivity predicate *} |
45137 | 70 |
"trans r \<longleftrightarrow> (ALL x y z. (x,y):r --> (y,z):r --> (x,z):r)" |
5978
fa2c2dd74f8c
moved diag (diagonal relation) from Univ to Relation
paulson
parents:
5608
diff
changeset
|
71 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
72 |
definition |
45137 | 73 |
irrefl :: "('a * 'a) set => bool" where |
74 |
"irrefl r \<longleftrightarrow> (\<forall>x. (x,x) \<notin> r)" |
|
29859
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
75 |
|
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
76 |
definition |
45137 | 77 |
total_on :: "'a set => ('a * 'a) set => bool" where |
78 |
"total_on A r \<longleftrightarrow> (\<forall>x\<in>A.\<forall>y\<in>A. x\<noteq>y \<longrightarrow> (x,y)\<in>r \<or> (y,x)\<in>r)" |
|
29859
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
79 |
|
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
80 |
abbreviation "total \<equiv> total_on UNIV" |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
81 |
|
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
82 |
definition |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
83 |
single_valued :: "('a * 'b) set => bool" where |
45137 | 84 |
"single_valued r \<longleftrightarrow> (ALL x y. (x,y):r --> (ALL z. (x,z):r --> y=z))" |
7014
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6806
diff
changeset
|
85 |
|
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
86 |
definition |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21210
diff
changeset
|
87 |
inv_image :: "('b * 'b) set => ('a => 'b) => ('a * 'a) set" where |
45137 | 88 |
"inv_image r f = {(x, y). (f x, f y) : r}" |
11136 | 89 |
|
12905 | 90 |
|
12913 | 91 |
subsection {* The identity relation *} |
12905 | 92 |
|
93 |
lemma IdI [intro]: "(a, a) : Id" |
|
26271 | 94 |
by (simp add: Id_def) |
12905 | 95 |
|
96 |
lemma IdE [elim!]: "p : Id ==> (!!x. p = (x, x) ==> P) ==> P" |
|
26271 | 97 |
by (unfold Id_def) (iprover elim: CollectE) |
12905 | 98 |
|
99 |
lemma pair_in_Id_conv [iff]: "((a, b) : Id) = (a = b)" |
|
26271 | 100 |
by (unfold Id_def) blast |
12905 | 101 |
|
30198 | 102 |
lemma refl_Id: "refl Id" |
103 |
by (simp add: refl_on_def) |
|
12905 | 104 |
|
105 |
lemma antisym_Id: "antisym Id" |
|
106 |
-- {* A strange result, since @{text Id} is also symmetric. *} |
|
26271 | 107 |
by (simp add: antisym_def) |
12905 | 108 |
|
19228 | 109 |
lemma sym_Id: "sym Id" |
26271 | 110 |
by (simp add: sym_def) |
19228 | 111 |
|
12905 | 112 |
lemma trans_Id: "trans Id" |
26271 | 113 |
by (simp add: trans_def) |
12905 | 114 |
|
115 |
||
12913 | 116 |
subsection {* Diagonal: identity over a set *} |
12905 | 117 |
|
30198 | 118 |
lemma Id_on_empty [simp]: "Id_on {} = {}" |
119 |
by (simp add: Id_on_def) |
|
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13639
diff
changeset
|
120 |
|
30198 | 121 |
lemma Id_on_eqI: "a = b ==> a : A ==> (a, b) : Id_on A" |
122 |
by (simp add: Id_on_def) |
|
12905 | 123 |
|
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
33218
diff
changeset
|
124 |
lemma Id_onI [intro!,no_atp]: "a : A ==> (a, a) : Id_on A" |
30198 | 125 |
by (rule Id_on_eqI) (rule refl) |
12905 | 126 |
|
30198 | 127 |
lemma Id_onE [elim!]: |
128 |
"c : Id_on A ==> (!!x. x : A ==> c = (x, x) ==> P) ==> P" |
|
12913 | 129 |
-- {* The general elimination rule. *} |
30198 | 130 |
by (unfold Id_on_def) (iprover elim!: UN_E singletonE) |
12905 | 131 |
|
30198 | 132 |
lemma Id_on_iff: "((x, y) : Id_on A) = (x = y & x : A)" |
26271 | 133 |
by blast |
12905 | 134 |
|
41792
ff3cb0c418b7
renamed "nitpick\_def" to "nitpick_unfold" to reflect its new semantics
blanchet
parents:
41056
diff
changeset
|
135 |
lemma Id_on_def' [nitpick_unfold, code]: |
44278
1220ecb81e8f
observe distinction between sets and predicates more properly
haftmann
parents:
41792
diff
changeset
|
136 |
"Id_on {x. A x} = Collect (\<lambda>(x, y). x = y \<and> A x)" |
1220ecb81e8f
observe distinction between sets and predicates more properly
haftmann
parents:
41792
diff
changeset
|
137 |
by auto |
40923
be80c93ac0a2
adding a nice definition of Id_on for quickcheck and nitpick
bulwahn
parents:
36772
diff
changeset
|
138 |
|
30198 | 139 |
lemma Id_on_subset_Times: "Id_on A \<subseteq> A \<times> A" |
26271 | 140 |
by blast |
12905 | 141 |
|
142 |
||
143 |
subsection {* Composition of two relations *} |
|
144 |
||
12913 | 145 |
lemma rel_compI [intro]: |
32235
8f9b8d14fc9f
"more standard" argument order of relation composition (op O)
krauss
parents:
31011
diff
changeset
|
146 |
"(a, b) : r ==> (b, c) : s ==> (a, c) : r O s" |
26271 | 147 |
by (unfold rel_comp_def) blast |
12905 | 148 |
|
12913 | 149 |
lemma rel_compE [elim!]: "xz : r O s ==> |
32235
8f9b8d14fc9f
"more standard" argument order of relation composition (op O)
krauss
parents:
31011
diff
changeset
|
150 |
(!!x y z. xz = (x, z) ==> (x, y) : r ==> (y, z) : s ==> P) ==> P" |
26271 | 151 |
by (unfold rel_comp_def) (iprover elim!: CollectE splitE exE conjE) |
12905 | 152 |
|
153 |
lemma rel_compEpair: |
|
32235
8f9b8d14fc9f
"more standard" argument order of relation composition (op O)
krauss
parents:
31011
diff
changeset
|
154 |
"(a, c) : r O s ==> (!!y. (a, y) : r ==> (y, c) : s ==> P) ==> P" |
26271 | 155 |
by (iprover elim: rel_compE Pair_inject ssubst) |
12905 | 156 |
|
157 |
lemma R_O_Id [simp]: "R O Id = R" |
|
26271 | 158 |
by fast |
12905 | 159 |
|
160 |
lemma Id_O_R [simp]: "Id O R = R" |
|
26271 | 161 |
by fast |
12905 | 162 |
|
23185 | 163 |
lemma rel_comp_empty1[simp]: "{} O R = {}" |
26271 | 164 |
by blast |
23185 | 165 |
|
166 |
lemma rel_comp_empty2[simp]: "R O {} = {}" |
|
26271 | 167 |
by blast |
23185 | 168 |
|
12905 | 169 |
lemma O_assoc: "(R O S) O T = R O (S O T)" |
26271 | 170 |
by blast |
12905 | 171 |
|
12913 | 172 |
lemma trans_O_subset: "trans r ==> r O r \<subseteq> r" |
26271 | 173 |
by (unfold trans_def) blast |
12905 | 174 |
|
12913 | 175 |
lemma rel_comp_mono: "r' \<subseteq> r ==> s' \<subseteq> s ==> (r' O s') \<subseteq> (r O s)" |
26271 | 176 |
by blast |
12905 | 177 |
|
178 |
lemma rel_comp_subset_Sigma: |
|
32235
8f9b8d14fc9f
"more standard" argument order of relation composition (op O)
krauss
parents:
31011
diff
changeset
|
179 |
"r \<subseteq> A \<times> B ==> s \<subseteq> B \<times> C ==> (r O s) \<subseteq> A \<times> C" |
26271 | 180 |
by blast |
12905 | 181 |
|
28008
f945f8d9ad4d
added distributivity of relation composition over union [simp]
krauss
parents:
26297
diff
changeset
|
182 |
lemma rel_comp_distrib[simp]: "R O (S \<union> T) = (R O S) \<union> (R O T)" |
f945f8d9ad4d
added distributivity of relation composition over union [simp]
krauss
parents:
26297
diff
changeset
|
183 |
by auto |
f945f8d9ad4d
added distributivity of relation composition over union [simp]
krauss
parents:
26297
diff
changeset
|
184 |
|
f945f8d9ad4d
added distributivity of relation composition over union [simp]
krauss
parents:
26297
diff
changeset
|
185 |
lemma rel_comp_distrib2[simp]: "(S \<union> T) O R = (S O R) \<union> (T O R)" |
f945f8d9ad4d
added distributivity of relation composition over union [simp]
krauss
parents:
26297
diff
changeset
|
186 |
by auto |
f945f8d9ad4d
added distributivity of relation composition over union [simp]
krauss
parents:
26297
diff
changeset
|
187 |
|
36772 | 188 |
lemma rel_comp_UNION_distrib: "s O UNION I r = UNION I (%i. s O r i)" |
189 |
by auto |
|
190 |
||
191 |
lemma rel_comp_UNION_distrib2: "UNION I r O s = UNION I (%i. r i O s)" |
|
192 |
by auto |
|
193 |
||
12913 | 194 |
|
195 |
subsection {* Reflexivity *} |
|
196 |
||
30198 | 197 |
lemma refl_onI: "r \<subseteq> A \<times> A ==> (!!x. x : A ==> (x, x) : r) ==> refl_on A r" |
198 |
by (unfold refl_on_def) (iprover intro!: ballI) |
|
12905 | 199 |
|
30198 | 200 |
lemma refl_onD: "refl_on A r ==> a : A ==> (a, a) : r" |
201 |
by (unfold refl_on_def) blast |
|
12905 | 202 |
|
30198 | 203 |
lemma refl_onD1: "refl_on A r ==> (x, y) : r ==> x : A" |
204 |
by (unfold refl_on_def) blast |
|
19228 | 205 |
|
30198 | 206 |
lemma refl_onD2: "refl_on A r ==> (x, y) : r ==> y : A" |
207 |
by (unfold refl_on_def) blast |
|
19228 | 208 |
|
30198 | 209 |
lemma refl_on_Int: "refl_on A r ==> refl_on B s ==> refl_on (A \<inter> B) (r \<inter> s)" |
210 |
by (unfold refl_on_def) blast |
|
19228 | 211 |
|
30198 | 212 |
lemma refl_on_Un: "refl_on A r ==> refl_on B s ==> refl_on (A \<union> B) (r \<union> s)" |
213 |
by (unfold refl_on_def) blast |
|
19228 | 214 |
|
30198 | 215 |
lemma refl_on_INTER: |
216 |
"ALL x:S. refl_on (A x) (r x) ==> refl_on (INTER S A) (INTER S r)" |
|
217 |
by (unfold refl_on_def) fast |
|
19228 | 218 |
|
30198 | 219 |
lemma refl_on_UNION: |
220 |
"ALL x:S. refl_on (A x) (r x) \<Longrightarrow> refl_on (UNION S A) (UNION S r)" |
|
221 |
by (unfold refl_on_def) blast |
|
19228 | 222 |
|
30198 | 223 |
lemma refl_on_empty[simp]: "refl_on {} {}" |
224 |
by(simp add:refl_on_def) |
|
26297 | 225 |
|
30198 | 226 |
lemma refl_on_Id_on: "refl_on A (Id_on A)" |
227 |
by (rule refl_onI [OF Id_on_subset_Times Id_onI]) |
|
19228 | 228 |
|
41792
ff3cb0c418b7
renamed "nitpick\_def" to "nitpick_unfold" to reflect its new semantics
blanchet
parents:
41056
diff
changeset
|
229 |
lemma refl_on_def' [nitpick_unfold, code]: |
41056
dcec9bc71ee9
adding a definition for refl_on which is friendly for quickcheck and nitpick
bulwahn
parents:
40923
diff
changeset
|
230 |
"refl_on A r = ((\<forall>(x, y) \<in> r. x : A \<and> y : A) \<and> (\<forall>x \<in> A. (x, x) : r))" |
dcec9bc71ee9
adding a definition for refl_on which is friendly for quickcheck and nitpick
bulwahn
parents:
40923
diff
changeset
|
231 |
by (auto intro: refl_onI dest: refl_onD refl_onD1 refl_onD2) |
12913 | 232 |
|
233 |
subsection {* Antisymmetry *} |
|
12905 | 234 |
|
235 |
lemma antisymI: |
|
236 |
"(!!x y. (x, y) : r ==> (y, x) : r ==> x=y) ==> antisym r" |
|
26271 | 237 |
by (unfold antisym_def) iprover |
12905 | 238 |
|
239 |
lemma antisymD: "antisym r ==> (a, b) : r ==> (b, a) : r ==> a = b" |
|
26271 | 240 |
by (unfold antisym_def) iprover |
12905 | 241 |
|
19228 | 242 |
lemma antisym_subset: "r \<subseteq> s ==> antisym s ==> antisym r" |
26271 | 243 |
by (unfold antisym_def) blast |
12913 | 244 |
|
19228 | 245 |
lemma antisym_empty [simp]: "antisym {}" |
26271 | 246 |
by (unfold antisym_def) blast |
19228 | 247 |
|
30198 | 248 |
lemma antisym_Id_on [simp]: "antisym (Id_on A)" |
26271 | 249 |
by (unfold antisym_def) blast |
19228 | 250 |
|
251 |
||
252 |
subsection {* Symmetry *} |
|
253 |
||
254 |
lemma symI: "(!!a b. (a, b) : r ==> (b, a) : r) ==> sym r" |
|
26271 | 255 |
by (unfold sym_def) iprover |
15177 | 256 |
|
257 |
lemma symD: "sym r ==> (a, b) : r ==> (b, a) : r" |
|
26271 | 258 |
by (unfold sym_def, blast) |
12905 | 259 |
|
19228 | 260 |
lemma sym_Int: "sym r ==> sym s ==> sym (r \<inter> s)" |
26271 | 261 |
by (fast intro: symI dest: symD) |
19228 | 262 |
|
263 |
lemma sym_Un: "sym r ==> sym s ==> sym (r \<union> s)" |
|
26271 | 264 |
by (fast intro: symI dest: symD) |
19228 | 265 |
|
266 |
lemma sym_INTER: "ALL x:S. sym (r x) ==> sym (INTER S r)" |
|
26271 | 267 |
by (fast intro: symI dest: symD) |
19228 | 268 |
|
269 |
lemma sym_UNION: "ALL x:S. sym (r x) ==> sym (UNION S r)" |
|
26271 | 270 |
by (fast intro: symI dest: symD) |
19228 | 271 |
|
30198 | 272 |
lemma sym_Id_on [simp]: "sym (Id_on A)" |
26271 | 273 |
by (rule symI) clarify |
19228 | 274 |
|
275 |
||
276 |
subsection {* Transitivity *} |
|
277 |
||
45012
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
278 |
lemma trans_join: |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
279 |
"trans r \<longleftrightarrow> (\<forall>(x, y1) \<in> r. \<forall>(y2, z) \<in> r. y1 = y2 \<longrightarrow> (x, z) \<in> r)" |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
280 |
by (auto simp add: trans_def) |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
281 |
|
12905 | 282 |
lemma transI: |
283 |
"(!!x y z. (x, y) : r ==> (y, z) : r ==> (x, z) : r) ==> trans r" |
|
26271 | 284 |
by (unfold trans_def) iprover |
12905 | 285 |
|
286 |
lemma transD: "trans r ==> (a, b) : r ==> (b, c) : r ==> (a, c) : r" |
|
26271 | 287 |
by (unfold trans_def) iprover |
12905 | 288 |
|
19228 | 289 |
lemma trans_Int: "trans r ==> trans s ==> trans (r \<inter> s)" |
26271 | 290 |
by (fast intro: transI elim: transD) |
19228 | 291 |
|
292 |
lemma trans_INTER: "ALL x:S. trans (r x) ==> trans (INTER S r)" |
|
26271 | 293 |
by (fast intro: transI elim: transD) |
19228 | 294 |
|
30198 | 295 |
lemma trans_Id_on [simp]: "trans (Id_on A)" |
26271 | 296 |
by (fast intro: transI elim: transD) |
19228 | 297 |
|
29859
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
298 |
lemma trans_diff_Id: " trans r \<Longrightarrow> antisym r \<Longrightarrow> trans (r-Id)" |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
299 |
unfolding antisym_def trans_def by blast |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
300 |
|
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
301 |
subsection {* Irreflexivity *} |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
302 |
|
45012
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
303 |
lemma irrefl_distinct: |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
304 |
"irrefl r \<longleftrightarrow> (\<forall>(x, y) \<in> r. x \<noteq> y)" |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
305 |
by (auto simp add: irrefl_def) |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
306 |
|
29859
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
307 |
lemma irrefl_diff_Id[simp]: "irrefl(r-Id)" |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
308 |
by(simp add:irrefl_def) |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
309 |
|
45139 | 310 |
|
29859
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
311 |
subsection {* Totality *} |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
312 |
|
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
313 |
lemma total_on_empty[simp]: "total_on {} r" |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
314 |
by(simp add:total_on_def) |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
315 |
|
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
316 |
lemma total_on_diff_Id[simp]: "total_on A (r-Id) = total_on A r" |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
317 |
by(simp add: total_on_def) |
12905 | 318 |
|
12913 | 319 |
subsection {* Converse *} |
320 |
||
321 |
lemma converse_iff [iff]: "((a,b): r^-1) = ((b,a) : r)" |
|
26271 | 322 |
by (simp add: converse_def) |
12905 | 323 |
|
13343 | 324 |
lemma converseI[sym]: "(a, b) : r ==> (b, a) : r^-1" |
26271 | 325 |
by (simp add: converse_def) |
12905 | 326 |
|
13343 | 327 |
lemma converseD[sym]: "(a,b) : r^-1 ==> (b, a) : r" |
26271 | 328 |
by (simp add: converse_def) |
12905 | 329 |
|
330 |
lemma converseE [elim!]: |
|
331 |
"yx : r^-1 ==> (!!x y. yx = (y, x) ==> (x, y) : r ==> P) ==> P" |
|
12913 | 332 |
-- {* More general than @{text converseD}, as it ``splits'' the member of the relation. *} |
26271 | 333 |
by (unfold converse_def) (iprover elim!: CollectE splitE bexE) |
12905 | 334 |
|
335 |
lemma converse_converse [simp]: "(r^-1)^-1 = r" |
|
26271 | 336 |
by (unfold converse_def) blast |
12905 | 337 |
|
338 |
lemma converse_rel_comp: "(r O s)^-1 = s^-1 O r^-1" |
|
26271 | 339 |
by blast |
12905 | 340 |
|
19228 | 341 |
lemma converse_Int: "(r \<inter> s)^-1 = r^-1 \<inter> s^-1" |
26271 | 342 |
by blast |
19228 | 343 |
|
344 |
lemma converse_Un: "(r \<union> s)^-1 = r^-1 \<union> s^-1" |
|
26271 | 345 |
by blast |
19228 | 346 |
|
347 |
lemma converse_INTER: "(INTER S r)^-1 = (INT x:S. (r x)^-1)" |
|
26271 | 348 |
by fast |
19228 | 349 |
|
350 |
lemma converse_UNION: "(UNION S r)^-1 = (UN x:S. (r x)^-1)" |
|
26271 | 351 |
by blast |
19228 | 352 |
|
12905 | 353 |
lemma converse_Id [simp]: "Id^-1 = Id" |
26271 | 354 |
by blast |
12905 | 355 |
|
30198 | 356 |
lemma converse_Id_on [simp]: "(Id_on A)^-1 = Id_on A" |
26271 | 357 |
by blast |
12905 | 358 |
|
30198 | 359 |
lemma refl_on_converse [simp]: "refl_on A (converse r) = refl_on A r" |
360 |
by (unfold refl_on_def) auto |
|
12905 | 361 |
|
19228 | 362 |
lemma sym_converse [simp]: "sym (converse r) = sym r" |
26271 | 363 |
by (unfold sym_def) blast |
19228 | 364 |
|
365 |
lemma antisym_converse [simp]: "antisym (converse r) = antisym r" |
|
26271 | 366 |
by (unfold antisym_def) blast |
12905 | 367 |
|
19228 | 368 |
lemma trans_converse [simp]: "trans (converse r) = trans r" |
26271 | 369 |
by (unfold trans_def) blast |
12905 | 370 |
|
19228 | 371 |
lemma sym_conv_converse_eq: "sym r = (r^-1 = r)" |
26271 | 372 |
by (unfold sym_def) fast |
19228 | 373 |
|
374 |
lemma sym_Un_converse: "sym (r \<union> r^-1)" |
|
26271 | 375 |
by (unfold sym_def) blast |
19228 | 376 |
|
377 |
lemma sym_Int_converse: "sym (r \<inter> r^-1)" |
|
26271 | 378 |
by (unfold sym_def) blast |
19228 | 379 |
|
29859
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
380 |
lemma total_on_converse[simp]: "total_on A (r^-1) = total_on A r" |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
381 |
by (auto simp: total_on_def) |
33bff35f1335
Moved Order_Relation into Library and moved some of it into Relation.
nipkow
parents:
29609
diff
changeset
|
382 |
|
12913 | 383 |
|
12905 | 384 |
subsection {* Domain *} |
385 |
||
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
33218
diff
changeset
|
386 |
declare Domain_def [no_atp] |
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23709
diff
changeset
|
387 |
|
12905 | 388 |
lemma Domain_iff: "(a : Domain r) = (EX y. (a, y) : r)" |
26271 | 389 |
by (unfold Domain_def) blast |
12905 | 390 |
|
391 |
lemma DomainI [intro]: "(a, b) : r ==> a : Domain r" |
|
26271 | 392 |
by (iprover intro!: iffD2 [OF Domain_iff]) |
12905 | 393 |
|
394 |
lemma DomainE [elim!]: |
|
395 |
"a : Domain r ==> (!!y. (a, y) : r ==> P) ==> P" |
|
26271 | 396 |
by (iprover dest!: iffD1 [OF Domain_iff]) |
12905 | 397 |
|
45012
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
398 |
lemma Domain_fst: |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
399 |
"Domain r = fst ` r" |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
400 |
by (auto simp add: image_def Bex_def) |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
401 |
|
12905 | 402 |
lemma Domain_empty [simp]: "Domain {} = {}" |
26271 | 403 |
by blast |
12905 | 404 |
|
32876 | 405 |
lemma Domain_empty_iff: "Domain r = {} \<longleftrightarrow> r = {}" |
406 |
by auto |
|
407 |
||
12905 | 408 |
lemma Domain_insert: "Domain (insert (a, b) r) = insert a (Domain r)" |
26271 | 409 |
by blast |
12905 | 410 |
|
411 |
lemma Domain_Id [simp]: "Domain Id = UNIV" |
|
26271 | 412 |
by blast |
12905 | 413 |
|
30198 | 414 |
lemma Domain_Id_on [simp]: "Domain (Id_on A) = A" |
26271 | 415 |
by blast |
12905 | 416 |
|
13830 | 417 |
lemma Domain_Un_eq: "Domain(A \<union> B) = Domain(A) \<union> Domain(B)" |
26271 | 418 |
by blast |
12905 | 419 |
|
13830 | 420 |
lemma Domain_Int_subset: "Domain(A \<inter> B) \<subseteq> Domain(A) \<inter> Domain(B)" |
26271 | 421 |
by blast |
12905 | 422 |
|
12913 | 423 |
lemma Domain_Diff_subset: "Domain(A) - Domain(B) \<subseteq> Domain(A - B)" |
26271 | 424 |
by blast |
12905 | 425 |
|
13830 | 426 |
lemma Domain_Union: "Domain (Union S) = (\<Union>A\<in>S. Domain A)" |
26271 | 427 |
by blast |
428 |
||
429 |
lemma Domain_converse[simp]: "Domain(r^-1) = Range r" |
|
430 |
by(auto simp:Range_def) |
|
12905 | 431 |
|
12913 | 432 |
lemma Domain_mono: "r \<subseteq> s ==> Domain r \<subseteq> Domain s" |
26271 | 433 |
by blast |
12905 | 434 |
|
36729 | 435 |
lemma fst_eq_Domain: "fst ` R = Domain R" |
44921 | 436 |
by force |
22172 | 437 |
|
29609 | 438 |
lemma Domain_dprod [simp]: "Domain (dprod r s) = uprod (Domain r) (Domain s)" |
439 |
by auto |
|
440 |
||
441 |
lemma Domain_dsum [simp]: "Domain (dsum r s) = usum (Domain r) (Domain s)" |
|
442 |
by auto |
|
443 |
||
12905 | 444 |
|
445 |
subsection {* Range *} |
|
446 |
||
447 |
lemma Range_iff: "(a : Range r) = (EX y. (y, a) : r)" |
|
26271 | 448 |
by (simp add: Domain_def Range_def) |
12905 | 449 |
|
450 |
lemma RangeI [intro]: "(a, b) : r ==> b : Range r" |
|
26271 | 451 |
by (unfold Range_def) (iprover intro!: converseI DomainI) |
12905 | 452 |
|
453 |
lemma RangeE [elim!]: "b : Range r ==> (!!x. (x, b) : r ==> P) ==> P" |
|
26271 | 454 |
by (unfold Range_def) (iprover elim!: DomainE dest!: converseD) |
12905 | 455 |
|
45012
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
456 |
lemma Range_snd: |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
457 |
"Range r = snd ` r" |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
458 |
by (auto simp add: image_def Bex_def) |
060f76635bfe
tuned specification and lemma distribution among theories; tuned proofs
haftmann
parents:
44921
diff
changeset
|
459 |
|
12905 | 460 |
lemma Range_empty [simp]: "Range {} = {}" |
26271 | 461 |
by blast |
12905 | 462 |
|
32876 | 463 |
lemma Range_empty_iff: "Range r = {} \<longleftrightarrow> r = {}" |
464 |
by auto |
|
465 |
||
12905 | 466 |
lemma Range_insert: "Range (insert (a, b) r) = insert b (Range r)" |
26271 | 467 |
by blast |
12905 | 468 |
|
469 |
lemma Range_Id [simp]: "Range Id = UNIV" |
|
26271 | 470 |
by blast |
12905 | 471 |
|
30198 | 472 |
lemma Range_Id_on [simp]: "Range (Id_on A) = A" |
26271 | 473 |
by auto |
12905 | 474 |
|
13830 | 475 |
lemma Range_Un_eq: "Range(A \<union> B) = Range(A) \<union> Range(B)" |
26271 | 476 |
by blast |
12905 | 477 |
|
13830 | 478 |
lemma Range_Int_subset: "Range(A \<inter> B) \<subseteq> Range(A) \<inter> Range(B)" |
26271 | 479 |
by blast |
12905 | 480 |
|
12913 | 481 |
lemma Range_Diff_subset: "Range(A) - Range(B) \<subseteq> Range(A - B)" |
26271 | 482 |
by blast |
12905 | 483 |
|
13830 | 484 |
lemma Range_Union: "Range (Union S) = (\<Union>A\<in>S. Range A)" |
26271 | 485 |
by blast |
486 |
||
487 |
lemma Range_converse[simp]: "Range(r^-1) = Domain r" |
|
488 |
by blast |
|
12905 | 489 |
|
36729 | 490 |
lemma snd_eq_Range: "snd ` R = Range R" |
44921 | 491 |
by force |
26271 | 492 |
|
493 |
||
494 |
subsection {* Field *} |
|
495 |
||
496 |
lemma mono_Field: "r \<subseteq> s \<Longrightarrow> Field r \<subseteq> Field s" |
|
497 |
by(auto simp:Field_def Domain_def Range_def) |
|
498 |
||
499 |
lemma Field_empty[simp]: "Field {} = {}" |
|
500 |
by(auto simp:Field_def) |
|
501 |
||
502 |
lemma Field_insert[simp]: "Field (insert (a,b) r) = {a,b} \<union> Field r" |
|
503 |
by(auto simp:Field_def) |
|
504 |
||
505 |
lemma Field_Un[simp]: "Field (r \<union> s) = Field r \<union> Field s" |
|
506 |
by(auto simp:Field_def) |
|
507 |
||
508 |
lemma Field_Union[simp]: "Field (\<Union>R) = \<Union>(Field ` R)" |
|
509 |
by(auto simp:Field_def) |
|
510 |
||
511 |
lemma Field_converse[simp]: "Field(r^-1) = Field r" |
|
512 |
by(auto simp:Field_def) |
|
22172 | 513 |
|
12905 | 514 |
|
515 |
subsection {* Image of a set under a relation *} |
|
516 |
||
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
33218
diff
changeset
|
517 |
declare Image_def [no_atp] |
24286
7619080e49f0
ATP blacklisting is now in theory data, attribute noatp
paulson
parents:
23709
diff
changeset
|
518 |
|
12913 | 519 |
lemma Image_iff: "(b : r``A) = (EX x:A. (x, b) : r)" |
26271 | 520 |
by (simp add: Image_def) |
12905 | 521 |
|
12913 | 522 |
lemma Image_singleton: "r``{a} = {b. (a, b) : r}" |
26271 | 523 |
by (simp add: Image_def) |
12905 | 524 |
|
12913 | 525 |
lemma Image_singleton_iff [iff]: "(b : r``{a}) = ((a, b) : r)" |
26271 | 526 |
by (rule Image_iff [THEN trans]) simp |
12905 | 527 |
|
35828
46cfc4b8112e
now use "Named_Thms" for "noatp", and renamed "noatp" to "no_atp"
blanchet
parents:
33218
diff
changeset
|
528 |
lemma ImageI [intro,no_atp]: "(a, b) : r ==> a : A ==> b : r``A" |
26271 | 529 |
by (unfold Image_def) blast |
12905 | 530 |
|
531 |
lemma ImageE [elim!]: |
|
12913 | 532 |
"b : r `` A ==> (!!x. (x, b) : r ==> x : A ==> P) ==> P" |
26271 | 533 |
by (unfold Image_def) (iprover elim!: CollectE bexE) |
12905 | 534 |
|
535 |
lemma rev_ImageI: "a : A ==> (a, b) : r ==> b : r `` A" |
|
536 |
-- {* This version's more effective when we already have the required @{text a} *} |
|
26271 | 537 |
by blast |
12905 | 538 |
|
539 |
lemma Image_empty [simp]: "R``{} = {}" |
|
26271 | 540 |
by blast |
12905 | 541 |
|
542 |
lemma Image_Id [simp]: "Id `` A = A" |
|
26271 | 543 |
by blast |
12905 | 544 |
|
30198 | 545 |
lemma Image_Id_on [simp]: "Id_on A `` B = A \<inter> B" |
26271 | 546 |
by blast |
13830 | 547 |
|
548 |
lemma Image_Int_subset: "R `` (A \<inter> B) \<subseteq> R `` A \<inter> R `` B" |
|
26271 | 549 |
by blast |
12905 | 550 |
|
13830 | 551 |
lemma Image_Int_eq: |
552 |
"single_valued (converse R) ==> R `` (A \<inter> B) = R `` A \<inter> R `` B" |
|
26271 | 553 |
by (simp add: single_valued_def, blast) |
12905 | 554 |
|
13830 | 555 |
lemma Image_Un: "R `` (A \<union> B) = R `` A \<union> R `` B" |
26271 | 556 |
by blast |
12905 | 557 |
|
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13639
diff
changeset
|
558 |
lemma Un_Image: "(R \<union> S) `` A = R `` A \<union> S `` A" |
26271 | 559 |
by blast |
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13639
diff
changeset
|
560 |
|
12913 | 561 |
lemma Image_subset: "r \<subseteq> A \<times> B ==> r``C \<subseteq> B" |
26271 | 562 |
by (iprover intro!: subsetI elim!: ImageE dest!: subsetD SigmaD2) |
12905 | 563 |
|
13830 | 564 |
lemma Image_eq_UN: "r``B = (\<Union>y\<in> B. r``{y})" |
12905 | 565 |
-- {* NOT suitable for rewriting *} |
26271 | 566 |
by blast |
12905 | 567 |
|
12913 | 568 |
lemma Image_mono: "r' \<subseteq> r ==> A' \<subseteq> A ==> (r' `` A') \<subseteq> (r `` A)" |
26271 | 569 |
by blast |
12905 | 570 |
|
13830 | 571 |
lemma Image_UN: "(r `` (UNION A B)) = (\<Union>x\<in>A. r `` (B x))" |
26271 | 572 |
by blast |
13830 | 573 |
|
574 |
lemma Image_INT_subset: "(r `` INTER A B) \<subseteq> (\<Inter>x\<in>A. r `` (B x))" |
|
26271 | 575 |
by blast |
12905 | 576 |
|
13830 | 577 |
text{*Converse inclusion requires some assumptions*} |
578 |
lemma Image_INT_eq: |
|
579 |
"[|single_valued (r\<inverse>); A\<noteq>{}|] ==> r `` INTER A B = (\<Inter>x\<in>A. r `` B x)" |
|
580 |
apply (rule equalityI) |
|
581 |
apply (rule Image_INT_subset) |
|
582 |
apply (simp add: single_valued_def, blast) |
|
583 |
done |
|
12905 | 584 |
|
12913 | 585 |
lemma Image_subset_eq: "(r``A \<subseteq> B) = (A \<subseteq> - ((r^-1) `` (-B)))" |
26271 | 586 |
by blast |
12905 | 587 |
|
588 |
||
12913 | 589 |
subsection {* Single valued relations *} |
590 |
||
591 |
lemma single_valuedI: |
|
12905 | 592 |
"ALL x y. (x,y):r --> (ALL z. (x,z):r --> y=z) ==> single_valued r" |
26271 | 593 |
by (unfold single_valued_def) |
12905 | 594 |
|
595 |
lemma single_valuedD: |
|
596 |
"single_valued r ==> (x, y) : r ==> (x, z) : r ==> y = z" |
|
26271 | 597 |
by (simp add: single_valued_def) |
12905 | 598 |
|
19228 | 599 |
lemma single_valued_rel_comp: |
600 |
"single_valued r ==> single_valued s ==> single_valued (r O s)" |
|
26271 | 601 |
by (unfold single_valued_def) blast |
19228 | 602 |
|
603 |
lemma single_valued_subset: |
|
604 |
"r \<subseteq> s ==> single_valued s ==> single_valued r" |
|
26271 | 605 |
by (unfold single_valued_def) blast |
19228 | 606 |
|
607 |
lemma single_valued_Id [simp]: "single_valued Id" |
|
26271 | 608 |
by (unfold single_valued_def) blast |
19228 | 609 |
|
30198 | 610 |
lemma single_valued_Id_on [simp]: "single_valued (Id_on A)" |
26271 | 611 |
by (unfold single_valued_def) blast |
19228 | 612 |
|
12905 | 613 |
|
614 |
subsection {* Graphs given by @{text Collect} *} |
|
615 |
||
616 |
lemma Domain_Collect_split [simp]: "Domain{(x,y). P x y} = {x. EX y. P x y}" |
|
26271 | 617 |
by auto |
12905 | 618 |
|
619 |
lemma Range_Collect_split [simp]: "Range{(x,y). P x y} = {y. EX x. P x y}" |
|
26271 | 620 |
by auto |
12905 | 621 |
|
622 |
lemma Image_Collect_split [simp]: "{(x,y). P x y} `` A = {y. EX x:A. P x y}" |
|
26271 | 623 |
by auto |
12905 | 624 |
|
625 |
||
12913 | 626 |
subsection {* Inverse image *} |
12905 | 627 |
|
19228 | 628 |
lemma sym_inv_image: "sym r ==> sym (inv_image r f)" |
26271 | 629 |
by (unfold sym_def inv_image_def) blast |
19228 | 630 |
|
12913 | 631 |
lemma trans_inv_image: "trans r ==> trans (inv_image r f)" |
12905 | 632 |
apply (unfold trans_def inv_image_def) |
633 |
apply (simp (no_asm)) |
|
634 |
apply blast |
|
635 |
done |
|
636 |
||
32463
3a0a65ca2261
moved lemma Wellfounded.in_inv_image to Relation.thy
krauss
parents:
32235
diff
changeset
|
637 |
lemma in_inv_image[simp]: "((x,y) : inv_image r f) = ((f x, f y) : r)" |
3a0a65ca2261
moved lemma Wellfounded.in_inv_image to Relation.thy
krauss
parents:
32235
diff
changeset
|
638 |
by (auto simp:inv_image_def) |
3a0a65ca2261
moved lemma Wellfounded.in_inv_image to Relation.thy
krauss
parents:
32235
diff
changeset
|
639 |
|
33218 | 640 |
lemma converse_inv_image[simp]: "(inv_image R f)^-1 = inv_image (R^-1) f" |
641 |
unfolding inv_image_def converse_def by auto |
|
642 |
||
23709 | 643 |
|
29609 | 644 |
subsection {* Finiteness *} |
645 |
||
646 |
lemma finite_converse [iff]: "finite (r^-1) = finite r" |
|
647 |
apply (subgoal_tac "r^-1 = (%(x,y). (y,x))`r") |
|
648 |
apply simp |
|
649 |
apply (rule iffI) |
|
650 |
apply (erule finite_imageD [unfolded inj_on_def]) |
|
651 |
apply (simp split add: split_split) |
|
652 |
apply (erule finite_imageI) |
|
653 |
apply (simp add: converse_def image_def, auto) |
|
654 |
apply (rule bexI) |
|
655 |
prefer 2 apply assumption |
|
656 |
apply simp |
|
657 |
done |
|
658 |
||
32876 | 659 |
lemma finite_Domain: "finite r ==> finite (Domain r)" |
660 |
by (induct set: finite) (auto simp add: Domain_insert) |
|
661 |
||
662 |
lemma finite_Range: "finite r ==> finite (Range r)" |
|
663 |
by (induct set: finite) (auto simp add: Range_insert) |
|
29609 | 664 |
|
665 |
lemma finite_Field: "finite r ==> finite (Field r)" |
|
666 |
-- {* A finite relation has a finite field (@{text "= domain \<union> range"}. *} |
|
667 |
apply (induct set: finite) |
|
668 |
apply (auto simp add: Field_def Domain_insert Range_insert) |
|
669 |
done |
|
670 |
||
671 |
||
36728
ae397b810c8b
rule subrelI (for nice Isar proofs of relation inequalities)
krauss
parents:
35828
diff
changeset
|
672 |
subsection {* Miscellaneous *} |
ae397b810c8b
rule subrelI (for nice Isar proofs of relation inequalities)
krauss
parents:
35828
diff
changeset
|
673 |
|
ae397b810c8b
rule subrelI (for nice Isar proofs of relation inequalities)
krauss
parents:
35828
diff
changeset
|
674 |
text {* Version of @{thm[source] lfp_induct} for binary relations *} |
23709 | 675 |
|
676 |
lemmas lfp_induct2 = |
|
677 |
lfp_induct_set [of "(a, b)", split_format (complete)] |
|
678 |
||
36728
ae397b810c8b
rule subrelI (for nice Isar proofs of relation inequalities)
krauss
parents:
35828
diff
changeset
|
679 |
text {* Version of @{thm[source] subsetI} for binary relations *} |
ae397b810c8b
rule subrelI (for nice Isar proofs of relation inequalities)
krauss
parents:
35828
diff
changeset
|
680 |
|
ae397b810c8b
rule subrelI (for nice Isar proofs of relation inequalities)
krauss
parents:
35828
diff
changeset
|
681 |
lemma subrelI: "(\<And>x y. (x, y) \<in> r \<Longrightarrow> (x, y) \<in> s) \<Longrightarrow> r \<subseteq> s" |
ae397b810c8b
rule subrelI (for nice Isar proofs of relation inequalities)
krauss
parents:
35828
diff
changeset
|
682 |
by auto |
ae397b810c8b
rule subrelI (for nice Isar proofs of relation inequalities)
krauss
parents:
35828
diff
changeset
|
683 |
|
1128
64b30e3cc6d4
Trancl is now based on Relation which used to be in Integ.
nipkow
parents:
diff
changeset
|
684 |
end |