author | paulson |
Thu, 19 Aug 1999 15:11:12 +0200 | |
changeset 7283 | 5cfe2944910a |
parent 7031 | 972b5f62f476 |
child 7339 | 1b4d7a851b34 |
permissions | -rw-r--r-- |
1465 | 1 |
(* Title: HOL/prod |
923 | 2 |
ID: $Id$ |
1465 | 3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
923 | 4 |
Copyright 1991 University of Cambridge |
5 |
||
5810 | 6 |
Ordered Pairs, the Cartesian product type, the unit type |
923 | 7 |
*) |
8 |
||
9 |
(*This counts as a non-emptiness result for admitting 'a * 'b as a type*) |
|
5069 | 10 |
Goalw [Prod_def] "Pair_Rep a b : Prod"; |
923 | 11 |
by (EVERY1 [rtac CollectI, rtac exI, rtac exI, rtac refl]); |
12 |
qed "ProdI"; |
|
13 |
||
14 |
val [major] = goalw Prod.thy [Pair_Rep_def] |
|
15 |
"Pair_Rep a b = Pair_Rep a' b' ==> a=a' & b=b'"; |
|
16 |
by (EVERY1 [rtac (major RS fun_cong RS fun_cong RS subst), |
|
1465 | 17 |
rtac conjI, rtac refl, rtac refl]); |
923 | 18 |
qed "Pair_Rep_inject"; |
19 |
||
5069 | 20 |
Goal "inj_on Abs_Prod Prod"; |
4830 | 21 |
by (rtac inj_on_inverseI 1); |
923 | 22 |
by (etac Abs_Prod_inverse 1); |
4830 | 23 |
qed "inj_on_Abs_Prod"; |
923 | 24 |
|
5316 | 25 |
val prems = Goalw [Pair_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
26 |
"[| (a, b) = (a',b'); [| a=a'; b=b' |] ==> R |] ==> R"; |
4830 | 27 |
by (rtac (inj_on_Abs_Prod RS inj_onD RS Pair_Rep_inject RS conjE) 1); |
923 | 28 |
by (REPEAT (ares_tac (prems@[ProdI]) 1)); |
29 |
qed "Pair_inject"; |
|
30 |
||
5069 | 31 |
Goal "((a,b) = (a',b')) = (a=a' & b=b')"; |
4089 | 32 |
by (blast_tac (claset() addSEs [Pair_inject]) 1); |
923 | 33 |
qed "Pair_eq"; |
3429 | 34 |
AddIffs [Pair_eq]; |
923 | 35 |
|
5069 | 36 |
Goalw [fst_def] "fst((a,b)) = a"; |
4534 | 37 |
by (Blast_tac 1); |
923 | 38 |
qed "fst_conv"; |
5069 | 39 |
Goalw [snd_def] "snd((a,b)) = b"; |
4534 | 40 |
by (Blast_tac 1); |
923 | 41 |
qed "snd_conv"; |
4534 | 42 |
Addsimps [fst_conv, snd_conv]; |
923 | 43 |
|
5069 | 44 |
Goalw [Pair_def] "? x y. p = (x,y)"; |
923 | 45 |
by (rtac (rewrite_rule [Prod_def] Rep_Prod RS CollectE) 1); |
46 |
by (EVERY1[etac exE, etac exE, rtac exI, rtac exI, |
|
1465 | 47 |
rtac (Rep_Prod_inverse RS sym RS trans), etac arg_cong]); |
923 | 48 |
qed "PairE_lemma"; |
49 |
||
5316 | 50 |
val [prem] = Goal "[| !!x y. p = (x,y) ==> Q |] ==> Q"; |
923 | 51 |
by (rtac (PairE_lemma RS exE) 1); |
52 |
by (REPEAT (eresolve_tac [prem,exE] 1)); |
|
53 |
qed "PairE"; |
|
54 |
||
4819
ef2e8e2a10e1
improved pair_tac to call prune_params_tac afterwards
oheimb
parents:
4799
diff
changeset
|
55 |
fun pair_tac s = EVERY' [res_inst_tac [("p",s)] PairE, hyp_subst_tac, |
ef2e8e2a10e1
improved pair_tac to call prune_params_tac afterwards
oheimb
parents:
4799
diff
changeset
|
56 |
K prune_params_tac]; |
4134 | 57 |
|
4828 | 58 |
(* Do not add as rewrite rule: invalidates some proofs in IMP *) |
5069 | 59 |
Goal "p = (fst(p),snd(p))"; |
4828 | 60 |
by (pair_tac "p" 1); |
61 |
by (Asm_simp_tac 1); |
|
62 |
qed "surjective_pairing"; |
|
63 |
||
7031 | 64 |
Goal "? x y. z = (x, y)"; |
65 |
by (rtac exI 1); |
|
66 |
by (rtac exI 1); |
|
67 |
by (rtac surjective_pairing 1); |
|
68 |
qed "surj_pair"; |
|
4828 | 69 |
Addsimps [surj_pair]; |
70 |
||
71 |
||
5699 | 72 |
bind_thm ("split_paired_all", |
73 |
SplitPairedAll.rule (standard (surjective_pairing RS eq_reflection))); |
|
4828 | 74 |
(* |
75 |
Addsimps [split_paired_all] does not work with simplifier |
|
76 |
because it also affects premises in congrence rules, |
|
77 |
where is can lead to premises of the form !!a b. ... = ?P(a,b) |
|
78 |
which cannot be solved by reflexivity. |
|
79 |
*) |
|
80 |
||
1301 | 81 |
(* replace parameters of product type by individual component parameters *) |
82 |
local |
|
4819
ef2e8e2a10e1
improved pair_tac to call prune_params_tac afterwards
oheimb
parents:
4799
diff
changeset
|
83 |
fun is_pair (_,Type("*",_)) = true |
ef2e8e2a10e1
improved pair_tac to call prune_params_tac afterwards
oheimb
parents:
4799
diff
changeset
|
84 |
| is_pair _ = false; |
4828 | 85 |
fun exists_paired_all prem = exists is_pair (Logic.strip_params prem); |
86 |
val split_tac = full_simp_tac (HOL_basic_ss addsimps [split_paired_all]); |
|
1301 | 87 |
in |
4828 | 88 |
val split_all_tac = SUBGOAL (fn (prem,i) => |
89 |
if exists_paired_all prem then split_tac i else no_tac); |
|
1301 | 90 |
end; |
91 |
||
4828 | 92 |
claset_ref() := claset() addSWrapper ("split_all_tac", |
93 |
fn tac2 => split_all_tac ORELSE' tac2); |
|
3568
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
94 |
|
5069 | 95 |
Goal "(!x. P x) = (!a b. P(a,b))"; |
4650 | 96 |
by (Fast_tac 1); |
1301 | 97 |
qed "split_paired_All"; |
3568
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
98 |
Addsimps [split_paired_All]; |
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
99 |
(* AddIffs is not a good idea because it makes Blast_tac loop *) |
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
100 |
|
5715
5fc697ad232b
Added theorem prod_induct (needed for rep_datatype).
berghofe
parents:
5699
diff
changeset
|
101 |
bind_thm ("prod_induct", |
5fc697ad232b
Added theorem prod_induct (needed for rep_datatype).
berghofe
parents:
5699
diff
changeset
|
102 |
allI RS (allI RS (split_paired_All RS iffD2)) RS spec); |
5fc697ad232b
Added theorem prod_induct (needed for rep_datatype).
berghofe
parents:
5699
diff
changeset
|
103 |
|
5069 | 104 |
Goal "(? x. P x) = (? a b. P(a,b))"; |
4650 | 105 |
by (Fast_tac 1); |
3568
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
106 |
qed "split_paired_Ex"; |
4534 | 107 |
Addsimps [split_paired_Ex]; |
1301 | 108 |
|
5069 | 109 |
Goalw [split_def] "split c (a,b) = c a b"; |
4534 | 110 |
by (Simp_tac 1); |
923 | 111 |
qed "split"; |
4534 | 112 |
Addsimps [split]; |
923 | 113 |
|
5069 | 114 |
Goal "split Pair p = p"; |
4828 | 115 |
by (pair_tac "p" 1); |
116 |
by (Simp_tac 1); |
|
117 |
qed "split_Pair"; |
|
118 |
(*unused: val surjective_pairing2 = split_Pair RS sym;*) |
|
119 |
||
5069 | 120 |
Goal "!!s t. (s=t) = (fst(s)=fst(t) & snd(s)=snd(t))"; |
4828 | 121 |
by (split_all_tac 1); |
1264 | 122 |
by (Asm_simp_tac 1); |
923 | 123 |
qed "Pair_fst_snd_eq"; |
124 |
||
125 |
(*Prevents simplification of c: much faster*) |
|
7031 | 126 |
val [prem] = goal Prod.thy |
127 |
"p=q ==> split c p = split c q"; |
|
128 |
by (rtac (prem RS arg_cong) 1); |
|
129 |
qed "split_weak_cong"; |
|
923 | 130 |
|
7031 | 131 |
Goal "(%(x,y). f(x,y)) = f"; |
132 |
by (rtac ext 1); |
|
133 |
by (split_all_tac 1); |
|
134 |
by (rtac split 1); |
|
135 |
qed "split_eta"; |
|
1655 | 136 |
|
7031 | 137 |
val prems = Goal "(!!x y. f x y = g(x,y)) ==> (%(x,y). f x y) = g"; |
138 |
by (asm_simp_tac (simpset() addsimps prems@[split_eta]) 1); |
|
139 |
qed "cond_split_eta"; |
|
5294 | 140 |
|
141 |
(*simplification procedure for cond_split_eta. |
|
142 |
using split_eta a rewrite rule is not general enough, and using |
|
143 |
cond_split_eta directly would render some existing proofs very inefficient*) |
|
144 |
local |
|
6394 | 145 |
val split_eta_pat = Thm.read_cterm (Theory.sign_of thy) |
5294 | 146 |
("split (%x. split (%y. f x y))", HOLogic.termTVar); |
5553 | 147 |
val split_eta_meta_eq = standard (mk_meta_eq cond_split_eta); |
5294 | 148 |
fun Pair_pat 0 (Bound 0) = true |
149 |
| Pair_pat k (Const ("Pair", _) $ Bound m $ t) = |
|
150 |
m = k andalso Pair_pat (k-1) t |
|
151 |
| Pair_pat _ _ = false; |
|
152 |
fun split_pat k (Abs (_, _, f $ |
|
153 |
(Const ("Pair",_) $ Bound m $ |
|
154 |
(Const ("Pair",_) $ Bound n $ t)))) = |
|
155 |
if m = k andalso n = k-1 andalso Pair_pat (k-2) t |
|
156 |
then Some f else None |
|
157 |
| split_pat k (Const ("split", _) $ Abs (_, _, t)) = split_pat (k+1) t |
|
158 |
| split_pat k _ = None; |
|
5361 | 159 |
fun proc sg _ (s as |
5294 | 160 |
(Const ("split", _) $ Abs (_, _, |
161 |
(Const ("split", _) $ Abs (_, _, t))))) = (case split_pat 2 t of |
|
162 |
Some f => (let val fvar = Free ("f", fastype_of f); |
|
163 |
fun atom_fun t = if t = f then fvar else atom t |
|
164 |
and atom (Abs (x, T, t)) = Abs (x, T,atom_fun t) |
|
165 |
| atom (t $ u) = atom_fun t $ atom_fun u |
|
166 |
| atom x = x; |
|
5361 | 167 |
val ct = cterm_of sg (HOLogic.mk_Trueprop |
5294 | 168 |
(HOLogic.mk_eq (atom_fun s,fvar))); |
169 |
val ss = HOL_basic_ss addsimps [cond_split_eta]; |
|
5553 | 170 |
in Some (mk_meta_eq (prove_goalw_cterm [] ct (K [simp_tac ss 1]))) end) |
5294 | 171 |
| None => None) |
172 |
| proc _ _ _ = None; |
|
173 |
||
174 |
in |
|
175 |
val split_eta_proc = Simplifier.mk_simproc "split_eta" [split_eta_pat] proc; |
|
176 |
end; |
|
177 |
||
178 |
Addsimprocs [split_eta_proc]; |
|
179 |
||
7031 | 180 |
Goal "(%(x,y). P x y) z = P (fst z) (snd z)"; |
181 |
by (stac surjective_pairing 1 THEN rtac split 1); |
|
182 |
qed "split_beta"; |
|
4134 | 183 |
|
923 | 184 |
(*For use with split_tac and the simplifier*) |
5069 | 185 |
Goal "R (split c p) = (! x y. p = (x,y) --> R (c x y))"; |
923 | 186 |
by (stac surjective_pairing 1); |
187 |
by (stac split 1); |
|
2935 | 188 |
by (Blast_tac 1); |
4830 | 189 |
qed "split_split"; |
923 | 190 |
|
3568
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
191 |
(* could be done after split_tac has been speeded up significantly: |
4830 | 192 |
simpset_ref() := simpset() addsplits [split_split]; |
3568
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
193 |
precompute the constants involved and don't do anything unless |
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
194 |
the current goal contains one of those constants |
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
195 |
*) |
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
196 |
|
5069 | 197 |
Goal "R (split c p) = (~(? x y. p = (x,y) & (~R (c x y))))"; |
4830 | 198 |
by (stac split_split 1); |
4435 | 199 |
by (Simp_tac 1); |
200 |
qed "expand_split_asm"; |
|
201 |
||
923 | 202 |
(** split used as a logical connective or set former **) |
203 |
||
2935 | 204 |
(*These rules are for use with blast_tac. |
923 | 205 |
Could instead call simp_tac/asm_full_simp_tac using split as rewrite.*) |
206 |
||
5069 | 207 |
Goal "!!p. [| !!a b. p=(a,b) ==> c a b |] ==> split c p"; |
1552 | 208 |
by (split_all_tac 1); |
1454
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
209 |
by (Asm_simp_tac 1); |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
210 |
qed "splitI2"; |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
211 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
212 |
Goal "c a b ==> split c (a,b)"; |
1264 | 213 |
by (Asm_simp_tac 1); |
923 | 214 |
qed "splitI"; |
215 |
||
5316 | 216 |
val prems = Goalw [split_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
217 |
"[| split c p; !!x y. [| p = (x,y); c x y |] ==> Q |] ==> Q"; |
923 | 218 |
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1)); |
219 |
qed "splitE"; |
|
220 |
||
7031 | 221 |
val major::prems = goal Prod.thy |
222 |
"[| Q (split P z); !!x y. [|z = (x, y); Q (P x y)|] ==> R \ |
|
223 |
\ |] ==> R"; |
|
224 |
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1)); |
|
225 |
by (rtac (split_beta RS subst) 1 THEN rtac major 1); |
|
226 |
qed "splitE2"; |
|
4134 | 227 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
228 |
Goal "split R (a,b) ==> R a b"; |
923 | 229 |
by (etac (split RS iffD1) 1); |
230 |
qed "splitD"; |
|
231 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
232 |
Goal "z: c a b ==> z: split c (a,b)"; |
1264 | 233 |
by (Asm_simp_tac 1); |
923 | 234 |
qed "mem_splitI"; |
235 |
||
5069 | 236 |
Goal "!!p. [| !!a b. p=(a,b) ==> z: c a b |] ==> z: split c p"; |
1552 | 237 |
by (split_all_tac 1); |
1454
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
238 |
by (Asm_simp_tac 1); |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
239 |
qed "mem_splitI2"; |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
240 |
|
5316 | 241 |
val prems = Goalw [split_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
242 |
"[| z: split c p; !!x y. [| p = (x,y); z: c x y |] ==> Q |] ==> Q"; |
923 | 243 |
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1)); |
244 |
qed "mem_splitE"; |
|
245 |
||
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
246 |
AddSIs [splitI, splitI2, mem_splitI, mem_splitI2]; |
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
247 |
AddSEs [splitE, mem_splitE]; |
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
248 |
|
4534 | 249 |
(* allows simplifications of nested splits in case of independent predicates *) |
5069 | 250 |
Goal "(%(a,b). P & Q a b) = (%ab. P & split Q ab)"; |
4534 | 251 |
by (rtac ext 1); |
252 |
by (Blast_tac 1); |
|
253 |
qed "split_part"; |
|
254 |
Addsimps [split_part]; |
|
255 |
||
5069 | 256 |
Goal "(@(x',y'). x = x' & y = y') = (x,y)"; |
4534 | 257 |
by (Blast_tac 1); |
258 |
qed "Eps_split_eq"; |
|
259 |
Addsimps [Eps_split_eq]; |
|
260 |
(* |
|
261 |
the following would be slightly more general, |
|
262 |
but cannot be used as rewrite rule: |
|
263 |
### Cannot add premise as rewrite rule because it contains (type) unknowns: |
|
264 |
### ?y = .x |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
265 |
Goal "[| P y; !!x. P x ==> x = y |] ==> (@(x',y). x = x' & P y) = (x,y)"; |
4534 | 266 |
by (rtac select_equality 1); |
267 |
by ( Simp_tac 1); |
|
268 |
by (split_all_tac 1); |
|
269 |
by (Asm_full_simp_tac 1); |
|
270 |
qed "Eps_split_eq"; |
|
271 |
*) |
|
272 |
||
923 | 273 |
(*** prod_fun -- action of the product functor upon functions ***) |
274 |
||
5069 | 275 |
Goalw [prod_fun_def] "prod_fun f g (a,b) = (f(a),g(b))"; |
923 | 276 |
by (rtac split 1); |
277 |
qed "prod_fun"; |
|
4521 | 278 |
Addsimps [prod_fun]; |
923 | 279 |
|
5278 | 280 |
Goal "prod_fun (f1 o f2) (g1 o g2) = ((prod_fun f1 g1) o (prod_fun f2 g2))"; |
923 | 281 |
by (rtac ext 1); |
4828 | 282 |
by (pair_tac "x" 1); |
4521 | 283 |
by (Asm_simp_tac 1); |
923 | 284 |
qed "prod_fun_compose"; |
285 |
||
5069 | 286 |
Goal "prod_fun (%x. x) (%y. y) = (%z. z)"; |
923 | 287 |
by (rtac ext 1); |
4828 | 288 |
by (pair_tac "z" 1); |
4521 | 289 |
by (Asm_simp_tac 1); |
923 | 290 |
qed "prod_fun_ident"; |
4521 | 291 |
Addsimps [prod_fun_ident]; |
923 | 292 |
|
5316 | 293 |
Goal "(a,b):r ==> (f(a),g(b)) : (prod_fun f g)``r"; |
923 | 294 |
by (rtac image_eqI 1); |
295 |
by (rtac (prod_fun RS sym) 1); |
|
5316 | 296 |
by (assume_tac 1); |
923 | 297 |
qed "prod_fun_imageI"; |
298 |
||
5316 | 299 |
val major::prems = Goal |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
300 |
"[| c: (prod_fun f g)``r; !!x y. [| c=(f(x),g(y)); (x,y):r |] ==> P \ |
923 | 301 |
\ |] ==> P"; |
302 |
by (rtac (major RS imageE) 1); |
|
303 |
by (res_inst_tac [("p","x")] PairE 1); |
|
304 |
by (resolve_tac prems 1); |
|
2935 | 305 |
by (Blast_tac 2); |
4089 | 306 |
by (blast_tac (claset() addIs [prod_fun]) 1); |
923 | 307 |
qed "prod_fun_imageE"; |
308 |
||
5788 | 309 |
AddIs [prod_fun_imageI]; |
310 |
AddSEs [prod_fun_imageE]; |
|
311 |
||
4521 | 312 |
|
923 | 313 |
(*** Disjoint union of a family of sets - Sigma ***) |
314 |
||
7031 | 315 |
Goalw [Sigma_def] "[| a:A; b:B(a) |] ==> (a,b) : Sigma A B"; |
316 |
by (REPEAT (ares_tac [singletonI,UN_I] 1)); |
|
317 |
qed "SigmaI"; |
|
923 | 318 |
|
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
319 |
AddSIs [SigmaI]; |
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
320 |
|
923 | 321 |
(*The general elimination rule*) |
7031 | 322 |
val major::prems = Goalw [Sigma_def] |
923 | 323 |
"[| c: Sigma A B; \ |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
324 |
\ !!x y.[| x:A; y:B(x); c=(x,y) |] ==> P \ |
7031 | 325 |
\ |] ==> P"; |
326 |
by (cut_facts_tac [major] 1); |
|
327 |
by (REPEAT (eresolve_tac [UN_E, singletonE] 1 ORELSE ares_tac prems 1)) ; |
|
328 |
qed "SigmaE"; |
|
923 | 329 |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
330 |
(** Elimination of (a,b):A*B -- introduces no eigenvariables **) |
7007 | 331 |
|
332 |
Goal "(a,b) : Sigma A B ==> a : A"; |
|
333 |
by (etac SigmaE 1); |
|
334 |
by (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ; |
|
335 |
qed "SigmaD1"; |
|
923 | 336 |
|
7007 | 337 |
Goal "(a,b) : Sigma A B ==> b : B(a)"; |
338 |
by (etac SigmaE 1); |
|
339 |
by (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ; |
|
340 |
qed "SigmaD2"; |
|
923 | 341 |
|
7007 | 342 |
val [major,minor]= goal Prod.thy |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
343 |
"[| (a,b) : Sigma A B; \ |
923 | 344 |
\ [| a:A; b:B(a) |] ==> P \ |
7007 | 345 |
\ |] ==> P"; |
346 |
by (rtac minor 1); |
|
347 |
by (rtac (major RS SigmaD1) 1); |
|
348 |
by (rtac (major RS SigmaD2) 1) ; |
|
349 |
qed "SigmaE2"; |
|
923 | 350 |
|
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
351 |
AddSEs [SigmaE2, SigmaE]; |
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
352 |
|
5316 | 353 |
val prems = Goal |
1642 | 354 |
"[| A<=C; !!x. x:A ==> B x <= D x |] ==> Sigma A B <= Sigma C D"; |
1515 | 355 |
by (cut_facts_tac prems 1); |
4089 | 356 |
by (blast_tac (claset() addIs (prems RL [subsetD])) 1); |
1515 | 357 |
qed "Sigma_mono"; |
358 |
||
7007 | 359 |
Goal "Sigma {} B = {}"; |
360 |
by (Blast_tac 1) ; |
|
361 |
qed "Sigma_empty1"; |
|
1618 | 362 |
|
7007 | 363 |
Goal "A Times {} = {}"; |
364 |
by (Blast_tac 1) ; |
|
365 |
qed "Sigma_empty2"; |
|
1618 | 366 |
|
367 |
Addsimps [Sigma_empty1,Sigma_empty2]; |
|
368 |
||
5069 | 369 |
Goal "((a,b): Sigma A B) = (a:A & b:B(a))"; |
2935 | 370 |
by (Blast_tac 1); |
1618 | 371 |
qed "mem_Sigma_iff"; |
3568
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
372 |
AddIffs [mem_Sigma_iff]; |
1618 | 373 |
|
6016 | 374 |
Goal "x:C ==> (A Times C <= B Times C) = (A <= B)"; |
375 |
by (Blast_tac 1); |
|
376 |
qed "Times_subset_cancel2"; |
|
377 |
||
378 |
Goal "x:C ==> (A Times C = B Times C) = (A = B)"; |
|
379 |
by (blast_tac (claset() addEs [equalityE]) 1); |
|
380 |
qed "Times_eq_cancel2"; |
|
381 |
||
5810 | 382 |
|
383 |
(*** Complex rules for Sigma ***) |
|
384 |
||
7031 | 385 |
Goal "{(a,b). P a & Q b} = Collect P Times Collect Q"; |
386 |
by (Blast_tac 1); |
|
387 |
qed "Collect_split"; |
|
388 |
||
4534 | 389 |
Addsimps [Collect_split]; |
1515 | 390 |
|
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
391 |
(*Suggested by Pierre Chartier*) |
5278 | 392 |
Goal "(UN (a,b):(A Times B). E a Times F b) = (UNION A E) Times (UNION B F)"; |
2935 | 393 |
by (Blast_tac 1); |
6830
f8aed3706af7
renamed UNION_... to UN_... (to fit the convention)
paulson
parents:
6394
diff
changeset
|
394 |
qed "UN_Times_distrib"; |
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
395 |
|
6016 | 396 |
Goal "(ALL z: Sigma A B. P z) = (ALL x:A. ALL y: B x. P(x,y))"; |
5810 | 397 |
by (Fast_tac 1); |
6016 | 398 |
qed "split_paired_Ball_Sigma"; |
399 |
Addsimps [split_paired_Ball_Sigma]; |
|
5810 | 400 |
|
6016 | 401 |
Goal "(EX z: Sigma A B. P z) = (EX x:A. EX y: B x. P(x,y))"; |
5810 | 402 |
by (Fast_tac 1); |
6016 | 403 |
qed "split_paired_Bex_Sigma"; |
404 |
Addsimps [split_paired_Bex_Sigma]; |
|
5810 | 405 |
|
406 |
Goal "(SIGMA i:I Un J. C(i)) = (SIGMA i:I. C(i)) Un (SIGMA j:J. C(j))"; |
|
407 |
by (Blast_tac 1); |
|
408 |
qed "Sigma_Un_distrib1"; |
|
409 |
||
410 |
Goal "(SIGMA i:I. A(i) Un B(i)) = (SIGMA i:I. A(i)) Un (SIGMA i:I. B(i))"; |
|
411 |
by (Blast_tac 1); |
|
412 |
qed "Sigma_Un_distrib2"; |
|
413 |
||
414 |
Goal "(SIGMA i:I Int J. C(i)) = (SIGMA i:I. C(i)) Int (SIGMA j:J. C(j))"; |
|
415 |
by (Blast_tac 1); |
|
416 |
qed "Sigma_Int_distrib1"; |
|
417 |
||
418 |
Goal "(SIGMA i:I. A(i) Int B(i)) = (SIGMA i:I. A(i)) Int (SIGMA i:I. B(i))"; |
|
419 |
by (Blast_tac 1); |
|
420 |
qed "Sigma_Int_distrib2"; |
|
421 |
||
422 |
Goal "(SIGMA i:I - J. C(i)) = (SIGMA i:I. C(i)) - (SIGMA j:J. C(j))"; |
|
423 |
by (Blast_tac 1); |
|
424 |
qed "Sigma_Diff_distrib1"; |
|
425 |
||
426 |
Goal "(SIGMA i:I. A(i) - B(i)) = (SIGMA i:I. A(i)) - (SIGMA i:I. B(i))"; |
|
427 |
by (Blast_tac 1); |
|
428 |
qed "Sigma_Diff_distrib2"; |
|
429 |
||
6016 | 430 |
Goal "Sigma (Union X) B = (UN A:X. Sigma A B)"; |
431 |
by (Blast_tac 1); |
|
432 |
qed "Sigma_Union"; |
|
433 |
||
5810 | 434 |
|
923 | 435 |
(** Exhaustion rule for unit -- a degenerate form of induction **) |
436 |
||
5069 | 437 |
Goalw [Unity_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
438 |
"u = ()"; |
2886 | 439 |
by (stac (rewrite_rule [unit_def] Rep_unit RS singletonD RS sym) 1); |
2880 | 440 |
by (rtac (Rep_unit_inverse RS sym) 1); |
923 | 441 |
qed "unit_eq"; |
1754
852093aeb0ab
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1746
diff
changeset
|
442 |
|
5088
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
443 |
(*simplification procedure for unit_eq. |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
444 |
Cannot use this rule directly -- it loops!*) |
5083 | 445 |
local |
6394 | 446 |
val unit_pat = Thm.cterm_of (Theory.sign_of thy) (Free ("x", HOLogic.unitT)); |
5553 | 447 |
val unit_meta_eq = standard (mk_meta_eq unit_eq); |
5083 | 448 |
fun proc _ _ t = |
449 |
if HOLogic.is_unit t then None |
|
450 |
else Some unit_meta_eq; |
|
451 |
in |
|
452 |
val unit_eq_proc = Simplifier.mk_simproc "unit_eq" [unit_pat] proc; |
|
453 |
end; |
|
454 |
||
455 |
Addsimprocs [unit_eq_proc]; |
|
456 |
||
457 |
||
5761 | 458 |
Goal "P () ==> P x"; |
459 |
by (Simp_tac 1); |
|
460 |
qed "unit_induct"; |
|
461 |
||
462 |
||
5088
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
463 |
(*This rewrite counters the effect of unit_eq_proc on (%u::unit. f u), |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
464 |
replacing it by f rather than by %u.f(). *) |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
465 |
Goal "(%u::unit. f()) = f"; |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
466 |
by (rtac ext 1); |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
467 |
by (Simp_tac 1); |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
468 |
qed "unit_abs_eta_conv"; |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
469 |
Addsimps [unit_abs_eta_conv]; |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
470 |
|
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
471 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
472 |
(*Attempts to remove occurrences of split, and pair-valued parameters*) |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
473 |
val remove_split = rewrite_rule [split RS eq_reflection] o |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
474 |
rule_by_tactic (TRYALL split_all_tac); |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
475 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
476 |
local |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
477 |
|
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
478 |
(*In ap_split S T u, term u expects separate arguments for the factors of S, |
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
479 |
with result type T. The call creates a new term expecting one argument |
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
480 |
of type S.*) |
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
481 |
fun ap_split (Type ("*", [T1, T2])) T3 u = |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
482 |
HOLogic.split_const (T1, T2, T3) $ |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
483 |
Abs("v", T1, |
2031 | 484 |
ap_split T2 T3 |
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
485 |
((ap_split T1 (HOLogic.prodT_factors T2 ---> T3) (incr_boundvars 1 u)) $ |
2031 | 486 |
Bound 0)) |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
487 |
| ap_split T T3 u = u; |
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
488 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
489 |
(*Curries any Var of function type in the rule*) |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
490 |
fun split_rule_var' (t as Var (v, Type ("fun", [T1, T2])), rl) = |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
491 |
let val T' = HOLogic.prodT_factors T1 ---> T2 |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
492 |
val newt = ap_split T1 T2 (Var (v, T')) |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
493 |
val cterm = Thm.cterm_of (#sign (rep_thm rl)) |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
494 |
in |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
495 |
instantiate ([], [(cterm t, cterm newt)]) rl |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
496 |
end |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
497 |
| split_rule_var' (t, rl) = rl; |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
498 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
499 |
in |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
500 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
501 |
val split_rule_var = standard o remove_split o split_rule_var'; |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
502 |
|
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
503 |
(*Curries ALL function variables occurring in a rule's conclusion*) |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
504 |
fun split_rule rl = remove_split (foldr split_rule_var' (term_vars (concl_of rl), rl)) |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
505 |
|> standard; |
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
506 |
|
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
507 |
end; |
5810 | 508 |
|
509 |