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 |
|
5320
|
10 |
claset_ref() := claset() addaltern ("trans_tac",trans_tac);
|
|
11 |
|
|
12 |
|
4776
|
13 |
(*** lessThan ***)
|
|
14 |
|
5069
|
15 |
Goalw [lessThan_def] "(i: lessThan k) = (i<k)";
|
4776
|
16 |
by (Blast_tac 1);
|
|
17 |
qed "lessThan_iff";
|
|
18 |
AddIffs [lessThan_iff];
|
|
19 |
|
5069
|
20 |
Goalw [lessThan_def] "lessThan 0 = {}";
|
4776
|
21 |
by (Simp_tac 1);
|
|
22 |
qed "lessThan_0";
|
|
23 |
Addsimps [lessThan_0];
|
|
24 |
|
5069
|
25 |
Goalw [lessThan_def] "lessThan (Suc k) = insert k (lessThan k)";
|
4776
|
26 |
by (simp_tac (simpset() addsimps [less_Suc_eq]) 1);
|
|
27 |
by (Blast_tac 1);
|
|
28 |
qed "lessThan_Suc";
|
|
29 |
|
5069
|
30 |
Goal "(UN m. lessThan m) = UNIV";
|
4776
|
31 |
by (Blast_tac 1);
|
|
32 |
qed "UN_lessThan_UNIV";
|
|
33 |
|
5069
|
34 |
Goalw [lessThan_def, atLeast_def, le_def]
|
4776
|
35 |
"Compl(lessThan k) = atLeast k";
|
|
36 |
by (Blast_tac 1);
|
|
37 |
qed "Compl_lessThan";
|
|
38 |
|
|
39 |
|
|
40 |
(*** greaterThan ***)
|
|
41 |
|
5069
|
42 |
Goalw [greaterThan_def] "(i: greaterThan k) = (k<i)";
|
4776
|
43 |
by (Blast_tac 1);
|
|
44 |
qed "greaterThan_iff";
|
|
45 |
AddIffs [greaterThan_iff];
|
|
46 |
|
5069
|
47 |
Goalw [greaterThan_def] "greaterThan 0 = range Suc";
|
4776
|
48 |
by (blast_tac (claset() addIs [Suc_pred RS sym]) 1);
|
|
49 |
qed "greaterThan_0";
|
|
50 |
Addsimps [greaterThan_0];
|
|
51 |
|
5069
|
52 |
Goalw [greaterThan_def] "greaterThan (Suc k) = greaterThan k - {Suc k}";
|
4776
|
53 |
by Safe_tac;
|
|
54 |
by (blast_tac (claset() addIs [less_trans]) 1);
|
|
55 |
by (asm_simp_tac (simpset() addsimps [le_Suc_eq, not_le_iff_less RS sym]) 1);
|
|
56 |
by (asm_simp_tac (simpset() addsimps [not_le_iff_less]) 1);
|
|
57 |
qed "greaterThan_Suc";
|
|
58 |
|
5069
|
59 |
Goal "(INT m. greaterThan m) = {}";
|
4776
|
60 |
by (Blast_tac 1);
|
|
61 |
qed "INT_greaterThan_UNIV";
|
|
62 |
|
5069
|
63 |
Goalw [greaterThan_def, atMost_def, le_def]
|
4776
|
64 |
"Compl(greaterThan k) = atMost k";
|
|
65 |
by (Blast_tac 1);
|
|
66 |
qed "Compl_greaterThan";
|
|
67 |
|
5069
|
68 |
Goalw [greaterThan_def, atMost_def, le_def]
|
4776
|
69 |
"Compl(atMost k) = greaterThan k";
|
|
70 |
by (Blast_tac 1);
|
|
71 |
qed "Compl_atMost";
|
|
72 |
|
5069
|
73 |
Goal "less_than ^^ {k} = greaterThan k";
|
4776
|
74 |
by (Blast_tac 1);
|
|
75 |
qed "Image_less_than";
|
|
76 |
|
|
77 |
Addsimps [Compl_greaterThan, Compl_atMost, Image_less_than];
|
|
78 |
|
|
79 |
(*** atLeast ***)
|
|
80 |
|
5069
|
81 |
Goalw [atLeast_def] "(i: atLeast k) = (k<=i)";
|
4776
|
82 |
by (Blast_tac 1);
|
|
83 |
qed "atLeast_iff";
|
|
84 |
AddIffs [atLeast_iff];
|
|
85 |
|
5069
|
86 |
Goalw [atLeast_def, UNIV_def] "atLeast 0 = UNIV";
|
4776
|
87 |
by (Simp_tac 1);
|
|
88 |
qed "atLeast_0";
|
|
89 |
Addsimps [atLeast_0];
|
|
90 |
|
5069
|
91 |
Goalw [atLeast_def] "atLeast (Suc k) = atLeast k - {k}";
|
4776
|
92 |
by (simp_tac (simpset() addsimps [Suc_le_eq]) 1);
|
|
93 |
by (simp_tac (simpset() addsimps [le_eq_less_or_eq]) 1);
|
|
94 |
by (Blast_tac 1);
|
|
95 |
qed "atLeast_Suc";
|
|
96 |
|
5069
|
97 |
Goal "(UN m. atLeast m) = UNIV";
|
4776
|
98 |
by (Blast_tac 1);
|
|
99 |
qed "UN_atLeast_UNIV";
|
|
100 |
|
5069
|
101 |
Goalw [lessThan_def, atLeast_def, le_def]
|
4776
|
102 |
"Compl(atLeast k) = lessThan k";
|
|
103 |
by (Blast_tac 1);
|
|
104 |
qed "Compl_atLeast";
|
|
105 |
|
5069
|
106 |
Goal "less_than^-1 ^^ {k} = lessThan k";
|
4776
|
107 |
by (Blast_tac 1);
|
|
108 |
qed "Image_inverse_less_than";
|
|
109 |
|
|
110 |
Addsimps [Compl_lessThan, Compl_atLeast, Image_inverse_less_than];
|
|
111 |
|
|
112 |
(*** atMost ***)
|
|
113 |
|
5069
|
114 |
Goalw [atMost_def] "(i: atMost k) = (i<=k)";
|
4776
|
115 |
by (Blast_tac 1);
|
|
116 |
qed "atMost_iff";
|
|
117 |
AddIffs [atMost_iff];
|
|
118 |
|
5069
|
119 |
Goalw [atMost_def] "atMost 0 = {0}";
|
4776
|
120 |
by (Simp_tac 1);
|
|
121 |
qed "atMost_0";
|
|
122 |
Addsimps [atMost_0];
|
|
123 |
|
5069
|
124 |
Goalw [atMost_def] "atMost (Suc k) = insert (Suc k) (atMost k)";
|
4776
|
125 |
by (simp_tac (simpset() addsimps [less_Suc_eq, le_eq_less_or_eq]) 1);
|
|
126 |
by (Blast_tac 1);
|
|
127 |
qed "atMost_Suc";
|
|
128 |
|
5069
|
129 |
Goal "(UN m. atMost m) = UNIV";
|
4776
|
130 |
by (Blast_tac 1);
|
|
131 |
qed "UN_atMost_UNIV";
|
|
132 |
|
5069
|
133 |
Goalw [atMost_def, le_def]
|
4776
|
134 |
"Compl(atMost k) = greaterThan k";
|
|
135 |
by (Blast_tac 1);
|
|
136 |
qed "Compl_atMost";
|
|
137 |
Addsimps [Compl_atMost];
|
|
138 |
|
|
139 |
|
|
140 |
(*** Combined properties ***)
|
|
141 |
|
5069
|
142 |
Goal "atMost n Int atLeast n = {n}";
|
4776
|
143 |
by (blast_tac (claset() addIs [le_anti_sym]) 1);
|
|
144 |
qed "atMost_Int_atLeast";
|
|
145 |
|
|
146 |
|
5232
|
147 |
|
|
148 |
|
|
149 |
(*** Finally, a few set-theoretic laws...
|
|
150 |
CAN BOOLEAN SIMPLIFICATION BE AUTOMATED? ***)
|
|
151 |
|
|
152 |
context Set.thy;
|
|
153 |
|
|
154 |
(** Rewrites rules to eliminate A. Conditions can be satisfied by letting B
|
|
155 |
be any set including A Int C and contained in A Un C, such as B=A or B=C.
|
|
156 |
**)
|
|
157 |
|
|
158 |
Goal "[| A Int C <= B; B <= A Un C |] \
|
|
159 |
\ ==> (A Int B) Un (Compl A Int C) = B Un C";
|
|
160 |
by (Blast_tac 1);
|
|
161 |
|
|
162 |
Goal "[| A Int C <= B; B <= A Un C |] \
|
|
163 |
\ ==> (A Un B) Int (Compl A Un C) = B Int C";
|
|
164 |
by (Blast_tac 1);
|
|
165 |
|
|
166 |
(*The base B=A*)
|
|
167 |
Goal "A Un (Compl A Int C) = A Un C";
|
|
168 |
by (Blast_tac 1);
|
|
169 |
|
|
170 |
Goal "A Int (Compl A Un C) = A Int C";
|
|
171 |
by (Blast_tac 1);
|
|
172 |
|
|
173 |
(*The base B=C*)
|
|
174 |
Goal "(A Int C) Un (Compl A Int C) = C";
|
|
175 |
by (Blast_tac 1);
|
|
176 |
|
|
177 |
Goal "(A Un C) Int (Compl A Un C) = C";
|
|
178 |
by (Blast_tac 1);
|
|
179 |
|
|
180 |
|
|
181 |
(** More ad-hoc rules **)
|
|
182 |
|
|
183 |
Goal "A Un B - (A - B) = B";
|
|
184 |
by (Blast_tac 1);
|
|
185 |
qed "Un_Diff_Diff";
|
|
186 |
|
|
187 |
Goal "A Int (B - C) Un C = A Int B Un C";
|
|
188 |
by (Blast_tac 1);
|
|
189 |
qed "Int_Diff_Un";
|
|
190 |
|
|
191 |
Goal "Union(B) Int A = (UN C:B. C Int A)";
|
|
192 |
by (Blast_tac 1);
|
|
193 |
qed "Int_Union2";
|
|
194 |
|
|
195 |
Goal "Union(B) Int A = Union((%C. C Int A)``B)";
|
|
196 |
by (Blast_tac 1);
|
|
197 |
qed "Int_Union_Union";
|
|
198 |
|