author | paulson |
Thu, 11 Nov 1999 10:25:17 +0100 | |
changeset 8005 | b64d86018785 |
parent 7915 | c7fd7eb3b0ef |
child 8128 | 3a5864b465e2 |
permissions | -rw-r--r-- |
4776 | 1 |
(* Title: HOL/LessThan/LessThan |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1998 University of Cambridge |
|
5 |
||
6 |
lessThan, greaterThan, atLeast, atMost |
|
7 |
*) |
|
8 |
||
9 |
||
7878
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
10 |
(*** Restrict [MOVE TO RELATION.THY??] ***) |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
11 |
|
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
12 |
Goalw [Restrict_def] "((x,y): Restrict A r) = ((x,y): r & x: A)"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
13 |
by (Blast_tac 1); |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
14 |
qed "Restrict_iff"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
15 |
AddIffs [Restrict_iff]; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
16 |
|
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
17 |
Goal "Restrict UNIV = id"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
18 |
by (rtac ext 1); |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
19 |
by (auto_tac (claset(), simpset() addsimps [Restrict_def])); |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
20 |
qed "Restrict_UNIV"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
21 |
Addsimps [Restrict_UNIV]; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
22 |
|
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
23 |
Goal "Restrict {} r = {}"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
24 |
by (auto_tac (claset(), simpset() addsimps [Restrict_def])); |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
25 |
qed "Restrict_empty"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
26 |
Addsimps [Restrict_empty]; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
27 |
|
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
28 |
Goalw [Restrict_def] "Restrict A (Restrict B r) = Restrict (A Int B) r"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
29 |
by (Blast_tac 1); |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
30 |
qed "Restrict_Int"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
31 |
Addsimps [Restrict_Int]; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
32 |
|
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
33 |
Goalw [Restrict_def] "Domain r <= A ==> Restrict A r = r"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
34 |
by Auto_tac; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
35 |
qed "Restrict_triv"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
36 |
|
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
37 |
Goalw [Restrict_def] "Restrict A r <= r"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
38 |
by Auto_tac; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
39 |
qed "Restrict_subset"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
40 |
|
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
41 |
Goalw [Restrict_def] |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
42 |
"[| A <= B; Restrict B r = Restrict B s |] \ |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
43 |
\ ==> Restrict A r = Restrict A s"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
44 |
by (blast_tac (claset() addSEs [equalityE]) 1); |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
45 |
qed "Restrict_eq_mono"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
46 |
|
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
47 |
Goalw [Restrict_def, image_def] |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
48 |
"[| s : RR; Restrict A r = Restrict A s |] \ |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
49 |
\ ==> Restrict A r : Restrict A `` RR"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
50 |
by Auto_tac; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
51 |
qed "Restrict_imageI"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
52 |
|
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
53 |
Goal "(Restrict A `` (Restrict A `` r - s)) = (Restrict A `` r - s)"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
54 |
by Auto_tac; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
55 |
by (rewrite_goals_tac [image_def, Restrict_def]); |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
56 |
by (Blast_tac 1); |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
57 |
qed "Restrict_image_Diff"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
58 |
|
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
59 |
(*Nothing to do with Restrict, but to specialized for Fun.ML?*) |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
60 |
Goal "f``(g``A - B) = (UN x: (A - g-`` B). {f(g(x))})"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
61 |
by (Blast_tac 1); |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
62 |
qed "image_Diff_image_eq"; |
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
63 |
|
7915
c7fd7eb3b0ef
ALMOST working version: LocalTo results commented out
paulson
parents:
7878
diff
changeset
|
64 |
Goal "Domain (Restrict A r) = A Int Domain r"; |
c7fd7eb3b0ef
ALMOST working version: LocalTo results commented out
paulson
parents:
7878
diff
changeset
|
65 |
by (Blast_tac 1); |
c7fd7eb3b0ef
ALMOST working version: LocalTo results commented out
paulson
parents:
7878
diff
changeset
|
66 |
qed "Domain_Restrict"; |
c7fd7eb3b0ef
ALMOST working version: LocalTo results commented out
paulson
parents:
7878
diff
changeset
|
67 |
|
c7fd7eb3b0ef
ALMOST working version: LocalTo results commented out
paulson
parents:
7878
diff
changeset
|
68 |
Goal "(Restrict A r) ^^ B = r ^^ (A Int B)"; |
c7fd7eb3b0ef
ALMOST working version: LocalTo results commented out
paulson
parents:
7878
diff
changeset
|
69 |
by (Blast_tac 1); |
c7fd7eb3b0ef
ALMOST working version: LocalTo results commented out
paulson
parents:
7878
diff
changeset
|
70 |
qed "Image_Restrict"; |
c7fd7eb3b0ef
ALMOST working version: LocalTo results commented out
paulson
parents:
7878
diff
changeset
|
71 |
|
c7fd7eb3b0ef
ALMOST working version: LocalTo results commented out
paulson
parents:
7878
diff
changeset
|
72 |
Addsimps [Domain_Restrict, Image_Restrict]; |
c7fd7eb3b0ef
ALMOST working version: LocalTo results commented out
paulson
parents:
7878
diff
changeset
|
73 |
|
c7fd7eb3b0ef
ALMOST working version: LocalTo results commented out
paulson
parents:
7878
diff
changeset
|
74 |
|
7878
43b03d412b82
working version with localTo[C] instead of localTo
paulson
parents:
7521
diff
changeset
|
75 |
|
4776 | 76 |
(*** lessThan ***) |
77 |
||
5069 | 78 |
Goalw [lessThan_def] "(i: lessThan k) = (i<k)"; |
4776 | 79 |
by (Blast_tac 1); |
80 |
qed "lessThan_iff"; |
|
81 |
AddIffs [lessThan_iff]; |
|
82 |
||
5069 | 83 |
Goalw [lessThan_def] "lessThan 0 = {}"; |
4776 | 84 |
by (Simp_tac 1); |
85 |
qed "lessThan_0"; |
|
86 |
Addsimps [lessThan_0]; |
|
87 |
||
5069 | 88 |
Goalw [lessThan_def] "lessThan (Suc k) = insert k (lessThan k)"; |
4776 | 89 |
by (simp_tac (simpset() addsimps [less_Suc_eq]) 1); |
90 |
by (Blast_tac 1); |
|
91 |
qed "lessThan_Suc"; |
|
92 |
||
5648 | 93 |
Goalw [lessThan_def, atMost_def] "lessThan (Suc k) = atMost k"; |
94 |
by (simp_tac (simpset() addsimps [less_Suc_eq_le]) 1); |
|
95 |
qed "lessThan_Suc_atMost"; |
|
96 |
||
6825 | 97 |
Goal "finite (lessThan k)"; |
98 |
by (induct_tac "k" 1); |
|
99 |
by (simp_tac (simpset() addsimps [lessThan_Suc]) 2); |
|
100 |
by Auto_tac; |
|
101 |
qed "finite_lessThan"; |
|
102 |
||
5069 | 103 |
Goal "(UN m. lessThan m) = UNIV"; |
4776 | 104 |
by (Blast_tac 1); |
105 |
qed "UN_lessThan_UNIV"; |
|
106 |
||
5069 | 107 |
Goalw [lessThan_def, atLeast_def, le_def] |
5490 | 108 |
"-lessThan k = atLeast k"; |
4776 | 109 |
by (Blast_tac 1); |
110 |
qed "Compl_lessThan"; |
|
111 |
||
7521 | 112 |
Goal "{k} - lessThan k = {k}"; |
113 |
by (Blast_tac 1); |
|
114 |
qed "single_Diff_lessThan"; |
|
115 |
Addsimps [single_Diff_lessThan]; |
|
4776 | 116 |
|
117 |
(*** greaterThan ***) |
|
118 |
||
5069 | 119 |
Goalw [greaterThan_def] "(i: greaterThan k) = (k<i)"; |
4776 | 120 |
by (Blast_tac 1); |
121 |
qed "greaterThan_iff"; |
|
122 |
AddIffs [greaterThan_iff]; |
|
123 |
||
5069 | 124 |
Goalw [greaterThan_def] "greaterThan 0 = range Suc"; |
4776 | 125 |
by (blast_tac (claset() addIs [Suc_pred RS sym]) 1); |
126 |
qed "greaterThan_0"; |
|
127 |
Addsimps [greaterThan_0]; |
|
128 |
||
5069 | 129 |
Goalw [greaterThan_def] "greaterThan (Suc k) = greaterThan k - {Suc k}"; |
5625 | 130 |
by (auto_tac (claset() addEs [linorder_neqE], simpset())); |
4776 | 131 |
qed "greaterThan_Suc"; |
132 |
||
5069 | 133 |
Goal "(INT m. greaterThan m) = {}"; |
4776 | 134 |
by (Blast_tac 1); |
135 |
qed "INT_greaterThan_UNIV"; |
|
136 |
||
5069 | 137 |
Goalw [greaterThan_def, atMost_def, le_def] |
5490 | 138 |
"-greaterThan k = atMost k"; |
4776 | 139 |
by (Blast_tac 1); |
140 |
qed "Compl_greaterThan"; |
|
141 |
||
5069 | 142 |
Goalw [greaterThan_def, atMost_def, le_def] |
5490 | 143 |
"-atMost k = greaterThan k"; |
4776 | 144 |
by (Blast_tac 1); |
145 |
qed "Compl_atMost"; |
|
146 |
||
5069 | 147 |
Goal "less_than ^^ {k} = greaterThan k"; |
4776 | 148 |
by (Blast_tac 1); |
149 |
qed "Image_less_than"; |
|
150 |
||
151 |
Addsimps [Compl_greaterThan, Compl_atMost, Image_less_than]; |
|
152 |
||
153 |
(*** atLeast ***) |
|
154 |
||
5069 | 155 |
Goalw [atLeast_def] "(i: atLeast k) = (k<=i)"; |
4776 | 156 |
by (Blast_tac 1); |
157 |
qed "atLeast_iff"; |
|
158 |
AddIffs [atLeast_iff]; |
|
159 |
||
5069 | 160 |
Goalw [atLeast_def, UNIV_def] "atLeast 0 = UNIV"; |
4776 | 161 |
by (Simp_tac 1); |
162 |
qed "atLeast_0"; |
|
163 |
Addsimps [atLeast_0]; |
|
164 |
||
5069 | 165 |
Goalw [atLeast_def] "atLeast (Suc k) = atLeast k - {k}"; |
4776 | 166 |
by (simp_tac (simpset() addsimps [Suc_le_eq]) 1); |
5596 | 167 |
by (simp_tac (simpset() addsimps [order_le_less]) 1); |
4776 | 168 |
by (Blast_tac 1); |
169 |
qed "atLeast_Suc"; |
|
170 |
||
5069 | 171 |
Goal "(UN m. atLeast m) = UNIV"; |
4776 | 172 |
by (Blast_tac 1); |
173 |
qed "UN_atLeast_UNIV"; |
|
174 |
||
5069 | 175 |
Goalw [lessThan_def, atLeast_def, le_def] |
5490 | 176 |
"-atLeast k = lessThan k"; |
4776 | 177 |
by (Blast_tac 1); |
178 |
qed "Compl_atLeast"; |
|
179 |
||
5069 | 180 |
Goal "less_than^-1 ^^ {k} = lessThan k"; |
4776 | 181 |
by (Blast_tac 1); |
182 |
qed "Image_inverse_less_than"; |
|
183 |
||
184 |
Addsimps [Compl_lessThan, Compl_atLeast, Image_inverse_less_than]; |
|
185 |
||
186 |
(*** atMost ***) |
|
187 |
||
5069 | 188 |
Goalw [atMost_def] "(i: atMost k) = (i<=k)"; |
4776 | 189 |
by (Blast_tac 1); |
190 |
qed "atMost_iff"; |
|
191 |
AddIffs [atMost_iff]; |
|
192 |
||
5069 | 193 |
Goalw [atMost_def] "atMost 0 = {0}"; |
4776 | 194 |
by (Simp_tac 1); |
195 |
qed "atMost_0"; |
|
196 |
Addsimps [atMost_0]; |
|
197 |
||
5069 | 198 |
Goalw [atMost_def] "atMost (Suc k) = insert (Suc k) (atMost k)"; |
5596 | 199 |
by (simp_tac (simpset() addsimps [less_Suc_eq, order_le_less]) 1); |
4776 | 200 |
by (Blast_tac 1); |
201 |
qed "atMost_Suc"; |
|
202 |
||
6825 | 203 |
Goal "finite (atMost k)"; |
204 |
by (induct_tac "k" 1); |
|
205 |
by (simp_tac (simpset() addsimps [atMost_Suc]) 2); |
|
206 |
by Auto_tac; |
|
207 |
qed "finite_atMost"; |
|
208 |
||
5069 | 209 |
Goal "(UN m. atMost m) = UNIV"; |
4776 | 210 |
by (Blast_tac 1); |
211 |
qed "UN_atMost_UNIV"; |
|
212 |
||
5069 | 213 |
Goalw [atMost_def, le_def] |
5490 | 214 |
"-atMost k = greaterThan k"; |
4776 | 215 |
by (Blast_tac 1); |
216 |
qed "Compl_atMost"; |
|
217 |
Addsimps [Compl_atMost]; |
|
218 |
||
219 |
||
220 |
(*** Combined properties ***) |
|
221 |
||
5069 | 222 |
Goal "atMost n Int atLeast n = {n}"; |
6707 | 223 |
by (blast_tac (claset() addIs [order_antisym]) 1); |
4776 | 224 |
qed "atMost_Int_atLeast"; |
225 |
||
226 |
||
5232 | 227 |
|
228 |
||
229 |
(*** Finally, a few set-theoretic laws... |
|
230 |
CAN BOOLEAN SIMPLIFICATION BE AUTOMATED? ***) |
|
231 |
||
232 |
context Set.thy; |
|
233 |
||
5490 | 234 |
(** Rewrite rules to eliminate A. Conditions can be satisfied by letting B |
5232 | 235 |
be any set including A Int C and contained in A Un C, such as B=A or B=C. |
236 |
**) |
|
237 |
||
238 |
Goal "[| A Int C <= B; B <= A Un C |] \ |
|
5490 | 239 |
\ ==> (A Int B) Un (-A Int C) = B Un C"; |
5232 | 240 |
by (Blast_tac 1); |
5490 | 241 |
qed "set_cancel1"; |
5232 | 242 |
|
243 |
Goal "[| A Int C <= B; B <= A Un C |] \ |
|
5490 | 244 |
\ ==> (A Un B) Int (-A Un C) = B Int C"; |
5232 | 245 |
by (Blast_tac 1); |
5490 | 246 |
qed "set_cancel2"; |
5232 | 247 |
|
248 |
(*The base B=A*) |
|
5490 | 249 |
Goal "A Un (-A Int C) = A Un C"; |
5232 | 250 |
by (Blast_tac 1); |
5490 | 251 |
qed "set_cancel3"; |
5232 | 252 |
|
5490 | 253 |
Goal "A Int (-A Un C) = A Int C"; |
5232 | 254 |
by (Blast_tac 1); |
5490 | 255 |
qed "set_cancel4"; |
5232 | 256 |
|
257 |
(*The base B=C*) |
|
5490 | 258 |
Goal "(A Int C) Un (-A Int C) = C"; |
5232 | 259 |
by (Blast_tac 1); |
5490 | 260 |
qed "set_cancel5"; |
5232 | 261 |
|
5490 | 262 |
Goal "(A Un C) Int (-A Un C) = C"; |
5232 | 263 |
by (Blast_tac 1); |
5490 | 264 |
qed "set_cancel6"; |
265 |
||
266 |
Addsimps [set_cancel1, set_cancel2, set_cancel3, |
|
267 |
set_cancel4, set_cancel5, set_cancel6]; |
|
5232 | 268 |
|
269 |
||
270 |
(** More ad-hoc rules **) |
|
271 |
||
272 |
Goal "A Un B - (A - B) = B"; |
|
273 |
by (Blast_tac 1); |
|
274 |
qed "Un_Diff_Diff"; |
|
5490 | 275 |
Addsimps [Un_Diff_Diff]; |
5232 | 276 |
|
277 |
Goal "A Int (B - C) Un C = A Int B Un C"; |
|
278 |
by (Blast_tac 1); |
|
279 |
qed "Int_Diff_Un"; |
|
280 |
||
281 |
Goal "Union(B) Int A = (UN C:B. C Int A)"; |
|
282 |
by (Blast_tac 1); |
|
283 |
qed "Int_Union2"; |
|
284 |
||
285 |
Goal "Union(B) Int A = Union((%C. C Int A)``B)"; |
|
286 |
by (Blast_tac 1); |
|
287 |
qed "Int_Union_Union"; |
|
288 |