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