equal
deleted
inserted
replaced
6 |
6 |
7 open Relation; |
7 open Relation; |
8 |
8 |
9 (** Identity relation **) |
9 (** Identity relation **) |
10 |
10 |
11 Goalw [id_def] "(a,a) : id"; |
11 Goalw [Id_def] "(a,a) : Id"; |
12 by (Blast_tac 1); |
12 by (Blast_tac 1); |
13 qed "idI"; |
13 qed "IdI"; |
14 |
14 |
15 val major::prems = Goalw [id_def] |
15 val major::prems = Goalw [Id_def] |
16 "[| p: id; !!x.[| p = (x,x) |] ==> P \ |
16 "[| p: Id; !!x.[| p = (x,x) |] ==> P \ |
17 \ |] ==> P"; |
17 \ |] ==> P"; |
18 by (rtac (major RS CollectE) 1); |
18 by (rtac (major RS CollectE) 1); |
19 by (etac exE 1); |
19 by (etac exE 1); |
20 by (eresolve_tac prems 1); |
20 by (eresolve_tac prems 1); |
21 qed "idE"; |
21 qed "IdE"; |
22 |
22 |
23 Goalw [id_def] "(a,b):id = (a=b)"; |
23 Goalw [Id_def] "(a,b):Id = (a=b)"; |
24 by (Blast_tac 1); |
24 by (Blast_tac 1); |
25 qed "pair_in_id_conv"; |
25 qed "pair_in_Id_conv"; |
26 Addsimps [pair_in_id_conv]; |
26 Addsimps [pair_in_Id_conv]; |
27 |
27 |
28 |
28 |
29 (** Composition of two relations **) |
29 (** Composition of two relations **) |
30 |
30 |
31 Goalw [comp_def] |
31 Goalw [comp_def] |
49 \ |] ==> P"; |
49 \ |] ==> P"; |
50 by (rtac compE 1); |
50 by (rtac compE 1); |
51 by (REPEAT (ares_tac prems 1 ORELSE eresolve_tac [Pair_inject,ssubst] 1)); |
51 by (REPEAT (ares_tac prems 1 ORELSE eresolve_tac [Pair_inject,ssubst] 1)); |
52 qed "compEpair"; |
52 qed "compEpair"; |
53 |
53 |
54 AddIs [compI, idI]; |
54 AddIs [compI, IdI]; |
55 AddSEs [compE, idE]; |
55 AddSEs [compE, IdE]; |
56 |
56 |
57 Goal "R O id = R"; |
57 Goal "R O Id = R"; |
58 by (Fast_tac 1); |
58 by (Fast_tac 1); |
59 qed "R_O_id"; |
59 qed "R_O_Id"; |
60 |
60 |
61 Goal "id O R = R"; |
61 Goal "Id O R = R"; |
62 by (Fast_tac 1); |
62 by (Fast_tac 1); |
63 qed "id_O_R"; |
63 qed "Id_O_R"; |
64 |
64 |
65 Addsimps [R_O_id,id_O_R]; |
65 Addsimps [R_O_Id,Id_O_R]; |
66 |
66 |
67 Goal "(R O S) O T = R O (S O T)"; |
67 Goal "(R O S) O T = R O (S O T)"; |
68 by (Blast_tac 1); |
68 by (Blast_tac 1); |
69 qed "O_assoc"; |
69 qed "O_assoc"; |
70 |
70 |
122 |
122 |
123 Goal "(r O s)^-1 = s^-1 O r^-1"; |
123 Goal "(r O s)^-1 = s^-1 O r^-1"; |
124 by (Blast_tac 1); |
124 by (Blast_tac 1); |
125 qed "converse_comp"; |
125 qed "converse_comp"; |
126 |
126 |
127 Goal "id^-1 = id"; |
127 Goal "Id^-1 = Id"; |
128 by (Blast_tac 1); |
128 by (Blast_tac 1); |
129 qed "converse_id"; |
129 qed "converse_Id"; |
130 Addsimps [converse_id]; |
130 Addsimps [converse_Id]; |
131 |
131 |
132 (** Domain **) |
132 (** Domain **) |
133 |
133 |
134 qed_goalw "Domain_iff" thy [Domain_def] |
134 qed_goalw "Domain_iff" thy [Domain_def] |
135 "a: Domain(r) = (EX y. (a,y): r)" |
135 "a: Domain(r) = (EX y. (a,y): r)" |
145 (REPEAT (ares_tac prems 1)) ]); |
145 (REPEAT (ares_tac prems 1)) ]); |
146 |
146 |
147 AddIs [DomainI]; |
147 AddIs [DomainI]; |
148 AddSEs [DomainE]; |
148 AddSEs [DomainE]; |
149 |
149 |
150 Goal "Domain id = UNIV"; |
150 Goal "Domain Id = UNIV"; |
151 by (Blast_tac 1); |
151 by (Blast_tac 1); |
152 qed "Domain_id"; |
152 qed "Domain_Id"; |
153 Addsimps [Domain_id]; |
153 Addsimps [Domain_Id]; |
154 |
154 |
155 (** Range **) |
155 (** Range **) |
156 |
156 |
157 qed_goalw "RangeI" thy [Range_def] "!!a b r.(a,b): r ==> b : Range(r)" |
157 qed_goalw "RangeI" thy [Range_def] "!!a b r.(a,b): r ==> b : Range(r)" |
158 (fn _ => [ (etac (converseI RS DomainI) 1) ]); |
158 (fn _ => [ (etac (converseI RS DomainI) 1) ]); |
165 (etac converseD 1) ]); |
165 (etac converseD 1) ]); |
166 |
166 |
167 AddIs [RangeI]; |
167 AddIs [RangeI]; |
168 AddSEs [RangeE]; |
168 AddSEs [RangeE]; |
169 |
169 |
170 Goal "Range id = UNIV"; |
170 Goal "Range Id = UNIV"; |
171 by (Blast_tac 1); |
171 by (Blast_tac 1); |
172 qed "Range_id"; |
172 qed "Range_Id"; |
173 Addsimps [Range_id]; |
173 Addsimps [Range_Id]; |
174 |
174 |
175 (*** Image of a set under a relation ***) |
175 (*** Image of a set under a relation ***) |
176 |
176 |
177 Blast.overloaded ("Relation.op ^^", HOLogic.dest_setT o domain_type); |
177 Blast.overloaded ("Relation.op ^^", HOLogic.dest_setT o domain_type); |
178 |
178 |
211 "R^^{} = {}" |
211 "R^^{} = {}" |
212 (fn _ => [ Blast_tac 1 ]); |
212 (fn _ => [ Blast_tac 1 ]); |
213 |
213 |
214 Addsimps [Image_empty]; |
214 Addsimps [Image_empty]; |
215 |
215 |
216 Goal "id ^^ A = A"; |
216 Goal "Id ^^ A = A"; |
217 by (Blast_tac 1); |
217 by (Blast_tac 1); |
218 qed "Image_id"; |
218 qed "Image_Id"; |
219 |
219 |
220 Addsimps [Image_id]; |
220 Addsimps [Image_Id]; |
221 |
221 |
222 qed_goal "Image_Int_subset" thy |
222 qed_goal "Image_Int_subset" thy |
223 "R ^^ (A Int B) <= R ^^ A Int R ^^ B" |
223 "R ^^ (A Int B) <= R ^^ A Int R ^^ B" |
224 (fn _ => [ Blast_tac 1 ]); |
224 (fn _ => [ Blast_tac 1 ]); |
225 |
225 |