author | paulson |
Wed, 25 Aug 1999 10:53:19 +0200 | |
changeset 7339 | 1b4d7a851b34 |
parent 7031 | 972b5f62f476 |
child 7495 | affcfd2830b7 |
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 |
|
7339 | 114 |
(*Subsumes the old split_Pair when f is the identity function*) |
115 |
Goal "split (%x y. f(x,y)) = f"; |
|
116 |
by (rtac ext 1); |
|
117 |
by (pair_tac "x" 1); |
|
4828 | 118 |
by (Simp_tac 1); |
7339 | 119 |
qed "split_Pair_apply"; |
120 |
||
121 |
(*Can't be added to simpset: loops!*) |
|
122 |
Goal "(SOME x. P x) = (SOME (a,b). P(a,b))"; |
|
123 |
by (simp_tac (simpset() addsimps [split_Pair_apply]) 1); |
|
124 |
qed "split_paired_Eps"; |
|
4828 | 125 |
|
5069 | 126 |
Goal "!!s t. (s=t) = (fst(s)=fst(t) & snd(s)=snd(t))"; |
4828 | 127 |
by (split_all_tac 1); |
1264 | 128 |
by (Asm_simp_tac 1); |
923 | 129 |
qed "Pair_fst_snd_eq"; |
130 |
||
131 |
(*Prevents simplification of c: much faster*) |
|
7031 | 132 |
val [prem] = goal Prod.thy |
133 |
"p=q ==> split c p = split c q"; |
|
134 |
by (rtac (prem RS arg_cong) 1); |
|
135 |
qed "split_weak_cong"; |
|
923 | 136 |
|
7031 | 137 |
Goal "(%(x,y). f(x,y)) = f"; |
138 |
by (rtac ext 1); |
|
139 |
by (split_all_tac 1); |
|
140 |
by (rtac split 1); |
|
141 |
qed "split_eta"; |
|
1655 | 142 |
|
7031 | 143 |
val prems = Goal "(!!x y. f x y = g(x,y)) ==> (%(x,y). f x y) = g"; |
144 |
by (asm_simp_tac (simpset() addsimps prems@[split_eta]) 1); |
|
145 |
qed "cond_split_eta"; |
|
5294 | 146 |
|
147 |
(*simplification procedure for cond_split_eta. |
|
148 |
using split_eta a rewrite rule is not general enough, and using |
|
149 |
cond_split_eta directly would render some existing proofs very inefficient*) |
|
150 |
local |
|
6394 | 151 |
val split_eta_pat = Thm.read_cterm (Theory.sign_of thy) |
5294 | 152 |
("split (%x. split (%y. f x y))", HOLogic.termTVar); |
5553 | 153 |
val split_eta_meta_eq = standard (mk_meta_eq cond_split_eta); |
5294 | 154 |
fun Pair_pat 0 (Bound 0) = true |
155 |
| Pair_pat k (Const ("Pair", _) $ Bound m $ t) = |
|
156 |
m = k andalso Pair_pat (k-1) t |
|
157 |
| Pair_pat _ _ = false; |
|
158 |
fun split_pat k (Abs (_, _, f $ |
|
159 |
(Const ("Pair",_) $ Bound m $ |
|
160 |
(Const ("Pair",_) $ Bound n $ t)))) = |
|
161 |
if m = k andalso n = k-1 andalso Pair_pat (k-2) t |
|
162 |
then Some f else None |
|
163 |
| split_pat k (Const ("split", _) $ Abs (_, _, t)) = split_pat (k+1) t |
|
164 |
| split_pat k _ = None; |
|
5361 | 165 |
fun proc sg _ (s as |
5294 | 166 |
(Const ("split", _) $ Abs (_, _, |
167 |
(Const ("split", _) $ Abs (_, _, t))))) = (case split_pat 2 t of |
|
168 |
Some f => (let val fvar = Free ("f", fastype_of f); |
|
169 |
fun atom_fun t = if t = f then fvar else atom t |
|
170 |
and atom (Abs (x, T, t)) = Abs (x, T,atom_fun t) |
|
171 |
| atom (t $ u) = atom_fun t $ atom_fun u |
|
172 |
| atom x = x; |
|
5361 | 173 |
val ct = cterm_of sg (HOLogic.mk_Trueprop |
5294 | 174 |
(HOLogic.mk_eq (atom_fun s,fvar))); |
175 |
val ss = HOL_basic_ss addsimps [cond_split_eta]; |
|
5553 | 176 |
in Some (mk_meta_eq (prove_goalw_cterm [] ct (K [simp_tac ss 1]))) end) |
5294 | 177 |
| None => None) |
178 |
| proc _ _ _ = None; |
|
179 |
||
180 |
in |
|
181 |
val split_eta_proc = Simplifier.mk_simproc "split_eta" [split_eta_pat] proc; |
|
182 |
end; |
|
183 |
||
184 |
Addsimprocs [split_eta_proc]; |
|
185 |
||
7031 | 186 |
Goal "(%(x,y). P x y) z = P (fst z) (snd z)"; |
187 |
by (stac surjective_pairing 1 THEN rtac split 1); |
|
188 |
qed "split_beta"; |
|
4134 | 189 |
|
923 | 190 |
(*For use with split_tac and the simplifier*) |
5069 | 191 |
Goal "R (split c p) = (! x y. p = (x,y) --> R (c x y))"; |
923 | 192 |
by (stac surjective_pairing 1); |
193 |
by (stac split 1); |
|
2935 | 194 |
by (Blast_tac 1); |
4830 | 195 |
qed "split_split"; |
923 | 196 |
|
3568
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
197 |
(* could be done after split_tac has been speeded up significantly: |
4830 | 198 |
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
|
199 |
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
|
200 |
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
|
201 |
*) |
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
202 |
|
5069 | 203 |
Goal "R (split c p) = (~(? x y. p = (x,y) & (~R (c x y))))"; |
4830 | 204 |
by (stac split_split 1); |
4435 | 205 |
by (Simp_tac 1); |
206 |
qed "expand_split_asm"; |
|
207 |
||
923 | 208 |
(** split used as a logical connective or set former **) |
209 |
||
2935 | 210 |
(*These rules are for use with blast_tac. |
923 | 211 |
Could instead call simp_tac/asm_full_simp_tac using split as rewrite.*) |
212 |
||
5069 | 213 |
Goal "!!p. [| !!a b. p=(a,b) ==> c a b |] ==> split c p"; |
1552 | 214 |
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
|
215 |
by (Asm_simp_tac 1); |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
216 |
qed "splitI2"; |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
217 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
218 |
Goal "c a b ==> split c (a,b)"; |
1264 | 219 |
by (Asm_simp_tac 1); |
923 | 220 |
qed "splitI"; |
221 |
||
5316 | 222 |
val prems = Goalw [split_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
223 |
"[| split c p; !!x y. [| p = (x,y); c x y |] ==> Q |] ==> Q"; |
923 | 224 |
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1)); |
225 |
qed "splitE"; |
|
226 |
||
7031 | 227 |
val major::prems = goal Prod.thy |
228 |
"[| Q (split P z); !!x y. [|z = (x, y); Q (P x y)|] ==> R \ |
|
229 |
\ |] ==> R"; |
|
230 |
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1)); |
|
231 |
by (rtac (split_beta RS subst) 1 THEN rtac major 1); |
|
232 |
qed "splitE2"; |
|
4134 | 233 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
234 |
Goal "split R (a,b) ==> R a b"; |
923 | 235 |
by (etac (split RS iffD1) 1); |
236 |
qed "splitD"; |
|
237 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
238 |
Goal "z: c a b ==> z: split c (a,b)"; |
1264 | 239 |
by (Asm_simp_tac 1); |
923 | 240 |
qed "mem_splitI"; |
241 |
||
5069 | 242 |
Goal "!!p. [| !!a b. p=(a,b) ==> z: c a b |] ==> z: split c p"; |
1552 | 243 |
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
|
244 |
by (Asm_simp_tac 1); |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
245 |
qed "mem_splitI2"; |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
246 |
|
5316 | 247 |
val prems = Goalw [split_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
248 |
"[| z: split c p; !!x y. [| p = (x,y); z: c x y |] ==> Q |] ==> Q"; |
923 | 249 |
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1)); |
250 |
qed "mem_splitE"; |
|
251 |
||
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
252 |
AddSIs [splitI, splitI2, mem_splitI, mem_splitI2]; |
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
253 |
AddSEs [splitE, mem_splitE]; |
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
254 |
|
4534 | 255 |
(* allows simplifications of nested splits in case of independent predicates *) |
5069 | 256 |
Goal "(%(a,b). P & Q a b) = (%ab. P & split Q ab)"; |
4534 | 257 |
by (rtac ext 1); |
258 |
by (Blast_tac 1); |
|
259 |
qed "split_part"; |
|
260 |
Addsimps [split_part]; |
|
261 |
||
5069 | 262 |
Goal "(@(x',y'). x = x' & y = y') = (x,y)"; |
4534 | 263 |
by (Blast_tac 1); |
264 |
qed "Eps_split_eq"; |
|
265 |
Addsimps [Eps_split_eq]; |
|
266 |
(* |
|
267 |
the following would be slightly more general, |
|
268 |
but cannot be used as rewrite rule: |
|
269 |
### Cannot add premise as rewrite rule because it contains (type) unknowns: |
|
270 |
### ?y = .x |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
271 |
Goal "[| P y; !!x. P x ==> x = y |] ==> (@(x',y). x = x' & P y) = (x,y)"; |
4534 | 272 |
by (rtac select_equality 1); |
273 |
by ( Simp_tac 1); |
|
274 |
by (split_all_tac 1); |
|
275 |
by (Asm_full_simp_tac 1); |
|
276 |
qed "Eps_split_eq"; |
|
277 |
*) |
|
278 |
||
923 | 279 |
(*** prod_fun -- action of the product functor upon functions ***) |
280 |
||
5069 | 281 |
Goalw [prod_fun_def] "prod_fun f g (a,b) = (f(a),g(b))"; |
923 | 282 |
by (rtac split 1); |
283 |
qed "prod_fun"; |
|
4521 | 284 |
Addsimps [prod_fun]; |
923 | 285 |
|
5278 | 286 |
Goal "prod_fun (f1 o f2) (g1 o g2) = ((prod_fun f1 g1) o (prod_fun f2 g2))"; |
923 | 287 |
by (rtac ext 1); |
4828 | 288 |
by (pair_tac "x" 1); |
4521 | 289 |
by (Asm_simp_tac 1); |
923 | 290 |
qed "prod_fun_compose"; |
291 |
||
5069 | 292 |
Goal "prod_fun (%x. x) (%y. y) = (%z. z)"; |
923 | 293 |
by (rtac ext 1); |
4828 | 294 |
by (pair_tac "z" 1); |
4521 | 295 |
by (Asm_simp_tac 1); |
923 | 296 |
qed "prod_fun_ident"; |
4521 | 297 |
Addsimps [prod_fun_ident]; |
923 | 298 |
|
5316 | 299 |
Goal "(a,b):r ==> (f(a),g(b)) : (prod_fun f g)``r"; |
923 | 300 |
by (rtac image_eqI 1); |
301 |
by (rtac (prod_fun RS sym) 1); |
|
5316 | 302 |
by (assume_tac 1); |
923 | 303 |
qed "prod_fun_imageI"; |
304 |
||
5316 | 305 |
val major::prems = Goal |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
306 |
"[| c: (prod_fun f g)``r; !!x y. [| c=(f(x),g(y)); (x,y):r |] ==> P \ |
923 | 307 |
\ |] ==> P"; |
308 |
by (rtac (major RS imageE) 1); |
|
309 |
by (res_inst_tac [("p","x")] PairE 1); |
|
310 |
by (resolve_tac prems 1); |
|
2935 | 311 |
by (Blast_tac 2); |
4089 | 312 |
by (blast_tac (claset() addIs [prod_fun]) 1); |
923 | 313 |
qed "prod_fun_imageE"; |
314 |
||
5788 | 315 |
AddIs [prod_fun_imageI]; |
316 |
AddSEs [prod_fun_imageE]; |
|
317 |
||
4521 | 318 |
|
923 | 319 |
(*** Disjoint union of a family of sets - Sigma ***) |
320 |
||
7031 | 321 |
Goalw [Sigma_def] "[| a:A; b:B(a) |] ==> (a,b) : Sigma A B"; |
322 |
by (REPEAT (ares_tac [singletonI,UN_I] 1)); |
|
323 |
qed "SigmaI"; |
|
923 | 324 |
|
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
325 |
AddSIs [SigmaI]; |
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
326 |
|
923 | 327 |
(*The general elimination rule*) |
7031 | 328 |
val major::prems = Goalw [Sigma_def] |
923 | 329 |
"[| c: Sigma A B; \ |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
330 |
\ !!x y.[| x:A; y:B(x); c=(x,y) |] ==> P \ |
7031 | 331 |
\ |] ==> P"; |
332 |
by (cut_facts_tac [major] 1); |
|
333 |
by (REPEAT (eresolve_tac [UN_E, singletonE] 1 ORELSE ares_tac prems 1)) ; |
|
334 |
qed "SigmaE"; |
|
923 | 335 |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
336 |
(** Elimination of (a,b):A*B -- introduces no eigenvariables **) |
7007 | 337 |
|
338 |
Goal "(a,b) : Sigma A B ==> a : A"; |
|
339 |
by (etac SigmaE 1); |
|
340 |
by (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ; |
|
341 |
qed "SigmaD1"; |
|
923 | 342 |
|
7007 | 343 |
Goal "(a,b) : Sigma A B ==> b : B(a)"; |
344 |
by (etac SigmaE 1); |
|
345 |
by (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ; |
|
346 |
qed "SigmaD2"; |
|
923 | 347 |
|
7007 | 348 |
val [major,minor]= goal Prod.thy |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
349 |
"[| (a,b) : Sigma A B; \ |
923 | 350 |
\ [| a:A; b:B(a) |] ==> P \ |
7007 | 351 |
\ |] ==> P"; |
352 |
by (rtac minor 1); |
|
353 |
by (rtac (major RS SigmaD1) 1); |
|
354 |
by (rtac (major RS SigmaD2) 1) ; |
|
355 |
qed "SigmaE2"; |
|
923 | 356 |
|
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
357 |
AddSEs [SigmaE2, SigmaE]; |
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
358 |
|
5316 | 359 |
val prems = Goal |
1642 | 360 |
"[| A<=C; !!x. x:A ==> B x <= D x |] ==> Sigma A B <= Sigma C D"; |
1515 | 361 |
by (cut_facts_tac prems 1); |
4089 | 362 |
by (blast_tac (claset() addIs (prems RL [subsetD])) 1); |
1515 | 363 |
qed "Sigma_mono"; |
364 |
||
7007 | 365 |
Goal "Sigma {} B = {}"; |
366 |
by (Blast_tac 1) ; |
|
367 |
qed "Sigma_empty1"; |
|
1618 | 368 |
|
7007 | 369 |
Goal "A Times {} = {}"; |
370 |
by (Blast_tac 1) ; |
|
371 |
qed "Sigma_empty2"; |
|
1618 | 372 |
|
373 |
Addsimps [Sigma_empty1,Sigma_empty2]; |
|
374 |
||
5069 | 375 |
Goal "((a,b): Sigma A B) = (a:A & b:B(a))"; |
2935 | 376 |
by (Blast_tac 1); |
1618 | 377 |
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
|
378 |
AddIffs [mem_Sigma_iff]; |
1618 | 379 |
|
6016 | 380 |
Goal "x:C ==> (A Times C <= B Times C) = (A <= B)"; |
381 |
by (Blast_tac 1); |
|
382 |
qed "Times_subset_cancel2"; |
|
383 |
||
384 |
Goal "x:C ==> (A Times C = B Times C) = (A = B)"; |
|
385 |
by (blast_tac (claset() addEs [equalityE]) 1); |
|
386 |
qed "Times_eq_cancel2"; |
|
387 |
||
5810 | 388 |
|
389 |
(*** Complex rules for Sigma ***) |
|
390 |
||
7031 | 391 |
Goal "{(a,b). P a & Q b} = Collect P Times Collect Q"; |
392 |
by (Blast_tac 1); |
|
393 |
qed "Collect_split"; |
|
394 |
||
4534 | 395 |
Addsimps [Collect_split]; |
1515 | 396 |
|
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
397 |
(*Suggested by Pierre Chartier*) |
5278 | 398 |
Goal "(UN (a,b):(A Times B). E a Times F b) = (UNION A E) Times (UNION B F)"; |
2935 | 399 |
by (Blast_tac 1); |
6830
f8aed3706af7
renamed UNION_... to UN_... (to fit the convention)
paulson
parents:
6394
diff
changeset
|
400 |
qed "UN_Times_distrib"; |
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
401 |
|
6016 | 402 |
Goal "(ALL z: Sigma A B. P z) = (ALL x:A. ALL y: B x. P(x,y))"; |
5810 | 403 |
by (Fast_tac 1); |
6016 | 404 |
qed "split_paired_Ball_Sigma"; |
405 |
Addsimps [split_paired_Ball_Sigma]; |
|
5810 | 406 |
|
6016 | 407 |
Goal "(EX z: Sigma A B. P z) = (EX x:A. EX y: B x. P(x,y))"; |
5810 | 408 |
by (Fast_tac 1); |
6016 | 409 |
qed "split_paired_Bex_Sigma"; |
410 |
Addsimps [split_paired_Bex_Sigma]; |
|
5810 | 411 |
|
412 |
Goal "(SIGMA i:I Un J. C(i)) = (SIGMA i:I. C(i)) Un (SIGMA j:J. C(j))"; |
|
413 |
by (Blast_tac 1); |
|
414 |
qed "Sigma_Un_distrib1"; |
|
415 |
||
416 |
Goal "(SIGMA i:I. A(i) Un B(i)) = (SIGMA i:I. A(i)) Un (SIGMA i:I. B(i))"; |
|
417 |
by (Blast_tac 1); |
|
418 |
qed "Sigma_Un_distrib2"; |
|
419 |
||
420 |
Goal "(SIGMA i:I Int J. C(i)) = (SIGMA i:I. C(i)) Int (SIGMA j:J. C(j))"; |
|
421 |
by (Blast_tac 1); |
|
422 |
qed "Sigma_Int_distrib1"; |
|
423 |
||
424 |
Goal "(SIGMA i:I. A(i) Int B(i)) = (SIGMA i:I. A(i)) Int (SIGMA i:I. B(i))"; |
|
425 |
by (Blast_tac 1); |
|
426 |
qed "Sigma_Int_distrib2"; |
|
427 |
||
428 |
Goal "(SIGMA i:I - J. C(i)) = (SIGMA i:I. C(i)) - (SIGMA j:J. C(j))"; |
|
429 |
by (Blast_tac 1); |
|
430 |
qed "Sigma_Diff_distrib1"; |
|
431 |
||
432 |
Goal "(SIGMA i:I. A(i) - B(i)) = (SIGMA i:I. A(i)) - (SIGMA i:I. B(i))"; |
|
433 |
by (Blast_tac 1); |
|
434 |
qed "Sigma_Diff_distrib2"; |
|
435 |
||
6016 | 436 |
Goal "Sigma (Union X) B = (UN A:X. Sigma A B)"; |
437 |
by (Blast_tac 1); |
|
438 |
qed "Sigma_Union"; |
|
439 |
||
5810 | 440 |
|
923 | 441 |
(** Exhaustion rule for unit -- a degenerate form of induction **) |
442 |
||
5069 | 443 |
Goalw [Unity_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
444 |
"u = ()"; |
2886 | 445 |
by (stac (rewrite_rule [unit_def] Rep_unit RS singletonD RS sym) 1); |
2880 | 446 |
by (rtac (Rep_unit_inverse RS sym) 1); |
923 | 447 |
qed "unit_eq"; |
1754
852093aeb0ab
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1746
diff
changeset
|
448 |
|
5088
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
449 |
(*simplification procedure for unit_eq. |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
450 |
Cannot use this rule directly -- it loops!*) |
5083 | 451 |
local |
6394 | 452 |
val unit_pat = Thm.cterm_of (Theory.sign_of thy) (Free ("x", HOLogic.unitT)); |
5553 | 453 |
val unit_meta_eq = standard (mk_meta_eq unit_eq); |
5083 | 454 |
fun proc _ _ t = |
455 |
if HOLogic.is_unit t then None |
|
456 |
else Some unit_meta_eq; |
|
457 |
in |
|
458 |
val unit_eq_proc = Simplifier.mk_simproc "unit_eq" [unit_pat] proc; |
|
459 |
end; |
|
460 |
||
461 |
Addsimprocs [unit_eq_proc]; |
|
462 |
||
463 |
||
5761 | 464 |
Goal "P () ==> P x"; |
465 |
by (Simp_tac 1); |
|
466 |
qed "unit_induct"; |
|
467 |
||
468 |
||
5088
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
469 |
(*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
|
470 |
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
|
471 |
Goal "(%u::unit. f()) = f"; |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
472 |
by (rtac ext 1); |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
473 |
by (Simp_tac 1); |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
474 |
qed "unit_abs_eta_conv"; |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
475 |
Addsimps [unit_abs_eta_conv]; |
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
476 |
|
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
477 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
478 |
(*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
|
479 |
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
|
480 |
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
|
481 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
482 |
local |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
483 |
|
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
484 |
(*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
|
485 |
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
|
486 |
of type S.*) |
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
487 |
fun ap_split (Type ("*", [T1, T2])) T3 u = |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
488 |
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
|
489 |
Abs("v", T1, |
2031 | 490 |
ap_split T2 T3 |
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
491 |
((ap_split T1 (HOLogic.prodT_factors T2 ---> T3) (incr_boundvars 1 u)) $ |
2031 | 492 |
Bound 0)) |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
493 |
| ap_split T T3 u = u; |
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
494 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
495 |
(*Curries any Var of function type in the rule*) |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
496 |
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
|
497 |
let val T' = HOLogic.prodT_factors T1 ---> T2 |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
498 |
val newt = ap_split T1 T2 (Var (v, T')) |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
499 |
val cterm = Thm.cterm_of (#sign (rep_thm rl)) |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
500 |
in |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
501 |
instantiate ([], [(cterm t, cterm newt)]) rl |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
502 |
end |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
503 |
| 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
|
504 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
505 |
in |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
506 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
507 |
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
|
508 |
|
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
509 |
(*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
|
510 |
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
|
511 |
|> standard; |
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
512 |
|
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
513 |
end; |
5810 | 514 |
|
515 |