author | wenzelm |
Tue, 03 Oct 2000 01:14:52 +0200 | |
changeset 10131 | 546686f0a6fb |
parent 10012 | 4961c73b5f60 |
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 |
||
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
9 |
(** unit **) |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
10 |
|
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
11 |
Goalw [Unity_def] |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
12 |
"u = ()"; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
13 |
by (stac (rewrite_rule [unit_def] Rep_unit RS singletonD RS sym) 1); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
14 |
by (rtac (Rep_unit_inverse RS sym) 1); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
15 |
qed "unit_eq"; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
16 |
|
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
17 |
(*simplification procedure for unit_eq. |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
18 |
Cannot use this rule directly -- it loops!*) |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
19 |
local |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
20 |
val unit_pat = Thm.cterm_of (Theory.sign_of (the_context ())) (Free ("x", HOLogic.unitT)); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
21 |
val unit_meta_eq = standard (mk_meta_eq unit_eq); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
22 |
fun proc _ _ t = |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
23 |
if HOLogic.is_unit t then None |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
24 |
else Some unit_meta_eq; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
25 |
in |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
26 |
val unit_eq_proc = Simplifier.mk_simproc "unit_eq" [unit_pat] proc; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
27 |
end; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
28 |
|
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
29 |
Addsimprocs [unit_eq_proc]; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
30 |
|
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
31 |
Goal "(!!x::unit. PROP P x) == PROP P ()"; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
32 |
by (Simp_tac 1); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
33 |
qed "unit_all_eq1"; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
34 |
|
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
35 |
Goal "(!!x::unit. PROP P) == PROP P"; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
36 |
by (rtac triv_forall_equality 1); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
37 |
qed "unit_all_eq2"; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
38 |
|
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
39 |
Goal "P () ==> P x"; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
40 |
by (Simp_tac 1); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
41 |
qed "unit_induct"; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
42 |
|
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
43 |
(*This rewrite counters the effect of unit_eq_proc on (%u::unit. f u), |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
44 |
replacing it by f rather than by %u.f(). *) |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
45 |
Goal "(%u::unit. f()) = f"; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
46 |
by (rtac ext 1); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
47 |
by (Simp_tac 1); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
48 |
qed "unit_abs_eta_conv"; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
49 |
Addsimps [unit_abs_eta_conv]; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
50 |
|
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
51 |
|
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
52 |
(** prod **) |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
53 |
|
5069 | 54 |
Goalw [Prod_def] "Pair_Rep a b : Prod"; |
923 | 55 |
by (EVERY1 [rtac CollectI, rtac exI, rtac exI, rtac refl]); |
56 |
qed "ProdI"; |
|
57 |
||
9969 | 58 |
Goalw [Pair_Rep_def] "Pair_Rep a b = Pair_Rep a' b' ==> a=a' & b=b'"; |
59 |
by (dtac (fun_cong RS fun_cong) 1); |
|
60 |
by (Blast_tac 1); |
|
923 | 61 |
qed "Pair_Rep_inject"; |
62 |
||
5069 | 63 |
Goal "inj_on Abs_Prod Prod"; |
4830 | 64 |
by (rtac inj_on_inverseI 1); |
923 | 65 |
by (etac Abs_Prod_inverse 1); |
4830 | 66 |
qed "inj_on_Abs_Prod"; |
923 | 67 |
|
5316 | 68 |
val prems = Goalw [Pair_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
69 |
"[| (a, b) = (a',b'); [| a=a'; b=b' |] ==> R |] ==> R"; |
4830 | 70 |
by (rtac (inj_on_Abs_Prod RS inj_onD RS Pair_Rep_inject RS conjE) 1); |
923 | 71 |
by (REPEAT (ares_tac (prems@[ProdI]) 1)); |
72 |
qed "Pair_inject"; |
|
73 |
||
5069 | 74 |
Goal "((a,b) = (a',b')) = (a=a' & b=b')"; |
4089 | 75 |
by (blast_tac (claset() addSEs [Pair_inject]) 1); |
923 | 76 |
qed "Pair_eq"; |
3429 | 77 |
AddIffs [Pair_eq]; |
923 | 78 |
|
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
79 |
Goalw [fst_def] "fst (a,b) = a"; |
4534 | 80 |
by (Blast_tac 1); |
923 | 81 |
qed "fst_conv"; |
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
82 |
Goalw [snd_def] "snd (a,b) = b"; |
4534 | 83 |
by (Blast_tac 1); |
923 | 84 |
qed "snd_conv"; |
4534 | 85 |
Addsimps [fst_conv, snd_conv]; |
923 | 86 |
|
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
87 |
Goal "fst (x, y) = a ==> x = a"; |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
88 |
by (Asm_full_simp_tac 1); |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
89 |
qed "fst_eqD"; |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
90 |
Goal "snd (x, y) = a ==> y = a"; |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
91 |
by (Asm_full_simp_tac 1); |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
92 |
qed "snd_eqD"; |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
93 |
|
5069 | 94 |
Goalw [Pair_def] "? x y. p = (x,y)"; |
923 | 95 |
by (rtac (rewrite_rule [Prod_def] Rep_Prod RS CollectE) 1); |
96 |
by (EVERY1[etac exE, etac exE, rtac exI, rtac exI, |
|
1465 | 97 |
rtac (Rep_Prod_inverse RS sym RS trans), etac arg_cong]); |
923 | 98 |
qed "PairE_lemma"; |
99 |
||
5316 | 100 |
val [prem] = Goal "[| !!x y. p = (x,y) ==> Q |] ==> Q"; |
923 | 101 |
by (rtac (PairE_lemma RS exE) 1); |
102 |
by (REPEAT (eresolve_tac [prem,exE] 1)); |
|
103 |
qed "PairE"; |
|
104 |
||
4819
ef2e8e2a10e1
improved pair_tac to call prune_params_tac afterwards
oheimb
parents:
4799
diff
changeset
|
105 |
fun pair_tac s = EVERY' [res_inst_tac [("p",s)] PairE, hyp_subst_tac, |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
106 |
K prune_params_tac]; |
4134 | 107 |
|
4828 | 108 |
(* Do not add as rewrite rule: invalidates some proofs in IMP *) |
5069 | 109 |
Goal "p = (fst(p),snd(p))"; |
4828 | 110 |
by (pair_tac "p" 1); |
111 |
by (Asm_simp_tac 1); |
|
112 |
qed "surjective_pairing"; |
|
9345 | 113 |
Addsimps [surjective_pairing RS sym]; |
4828 | 114 |
|
7031 | 115 |
Goal "? x y. z = (x, y)"; |
116 |
by (rtac exI 1); |
|
117 |
by (rtac exI 1); |
|
118 |
by (rtac surjective_pairing 1); |
|
119 |
qed "surj_pair"; |
|
4828 | 120 |
Addsimps [surj_pair]; |
121 |
||
122 |
||
5699 | 123 |
bind_thm ("split_paired_all", |
124 |
SplitPairedAll.rule (standard (surjective_pairing RS eq_reflection))); |
|
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
125 |
bind_thms ("split_tupled_all", [split_paired_all, unit_all_eq2]); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
126 |
|
4828 | 127 |
(* |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
128 |
Addsimps [split_paired_all] does not work with simplifier |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
129 |
because it also affects premises in congrence rules, |
4828 | 130 |
where is can lead to premises of the form !!a b. ... = ?P(a,b) |
131 |
which cannot be solved by reflexivity. |
|
132 |
*) |
|
133 |
||
1301 | 134 |
(* replace parameters of product type by individual component parameters *) |
135 |
local |
|
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
136 |
fun exists_paired_all prem = (* FIXME check deeper nesting of params!?! *) |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
137 |
Library.exists (can HOLogic.dest_prodT o #2) (Logic.strip_params prem); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
138 |
val ss = HOL_basic_ss |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
139 |
addsimps [split_paired_all, unit_all_eq2, unit_abs_eta_conv] |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
140 |
addsimprocs [unit_eq_proc]; |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
141 |
val split_tac = full_simp_tac ss; |
1301 | 142 |
in |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
143 |
val split_all_tac = SUBGOAL (fn (prem,i) => |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
144 |
if exists_paired_all prem then split_tac i else no_tac); |
1301 | 145 |
end; |
146 |
||
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
147 |
claset_ref() := claset() |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
148 |
addSWrapper ("split_all_tac", 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
|
149 |
|
5069 | 150 |
Goal "(!x. P x) = (!a b. P(a,b))"; |
4650 | 151 |
by (Fast_tac 1); |
1301 | 152 |
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
|
153 |
Addsimps [split_paired_All]; |
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
154 |
(* 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
|
155 |
|
5715
5fc697ad232b
Added theorem prod_induct (needed for rep_datatype).
berghofe
parents:
5699
diff
changeset
|
156 |
bind_thm ("prod_induct", |
5fc697ad232b
Added theorem prod_induct (needed for rep_datatype).
berghofe
parents:
5699
diff
changeset
|
157 |
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
|
158 |
|
5069 | 159 |
Goal "(? x. P x) = (? a b. P(a,b))"; |
4650 | 160 |
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
|
161 |
qed "split_paired_Ex"; |
4534 | 162 |
Addsimps [split_paired_Ex]; |
1301 | 163 |
|
5069 | 164 |
Goalw [split_def] "split c (a,b) = c a b"; |
4534 | 165 |
by (Simp_tac 1); |
923 | 166 |
qed "split"; |
4534 | 167 |
Addsimps [split]; |
923 | 168 |
|
7339 | 169 |
(*Subsumes the old split_Pair when f is the identity function*) |
170 |
Goal "split (%x y. f(x,y)) = f"; |
|
171 |
by (rtac ext 1); |
|
172 |
by (pair_tac "x" 1); |
|
4828 | 173 |
by (Simp_tac 1); |
7339 | 174 |
qed "split_Pair_apply"; |
175 |
||
176 |
(*Can't be added to simpset: loops!*) |
|
177 |
Goal "(SOME x. P x) = (SOME (a,b). P(a,b))"; |
|
178 |
by (simp_tac (simpset() addsimps [split_Pair_apply]) 1); |
|
179 |
qed "split_paired_Eps"; |
|
4828 | 180 |
|
5069 | 181 |
Goal "!!s t. (s=t) = (fst(s)=fst(t) & snd(s)=snd(t))"; |
4828 | 182 |
by (split_all_tac 1); |
1264 | 183 |
by (Asm_simp_tac 1); |
923 | 184 |
qed "Pair_fst_snd_eq"; |
185 |
||
10012 | 186 |
Goal "fst p = fst q ==> snd p = snd q ==> p = q"; |
187 |
by (asm_simp_tac (simpset() addsimps [Pair_fst_snd_eq]) 1); |
|
188 |
qed "prod_eqI"; |
|
189 |
AddXIs [prod_eqI]; |
|
190 |
||
923 | 191 |
(*Prevents simplification of c: much faster*) |
9969 | 192 |
Goal "p=q ==> split c p = split c q"; |
193 |
by (etac arg_cong 1); |
|
7031 | 194 |
qed "split_weak_cong"; |
923 | 195 |
|
7031 | 196 |
Goal "(%(x,y). f(x,y)) = f"; |
197 |
by (rtac ext 1); |
|
198 |
by (split_all_tac 1); |
|
199 |
by (rtac split 1); |
|
200 |
qed "split_eta"; |
|
1655 | 201 |
|
7031 | 202 |
val prems = Goal "(!!x y. f x y = g(x,y)) ==> (%(x,y). f x y) = g"; |
203 |
by (asm_simp_tac (simpset() addsimps prems@[split_eta]) 1); |
|
204 |
qed "cond_split_eta"; |
|
5294 | 205 |
|
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
206 |
(*simplification procedure for cond_split_eta. |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
207 |
using split_eta a rewrite rule is not general enough, and using |
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
208 |
cond_split_eta directly would render some existing proofs very inefficient. |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
209 |
similarly for split_beta. *) |
5294 | 210 |
local |
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
211 |
fun Pair_pat k 0 (Bound m) = (m = k) |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
212 |
| Pair_pat k i (Const ("Pair", _) $ Bound m $ t) = i > 0 andalso |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
213 |
m = k+i andalso Pair_pat k (i-1) t |
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
214 |
| Pair_pat _ _ _ = false; |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
215 |
fun no_args k i (Abs (_, _, t)) = no_args (k+1) i t |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
216 |
| no_args k i (t $ u) = no_args k i t andalso no_args k i u |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
217 |
| no_args k i (Bound m) = m < k orelse m > k+i |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
218 |
| no_args _ _ _ = true; |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
219 |
fun split_pat tp i (Abs (_,_,t)) = if tp 0 i t then Some (i,t) else None |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
220 |
| split_pat tp i (Const ("split", _) $ Abs (_, _, t)) = split_pat tp (i+1) t |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
221 |
| split_pat tp i _ = None; |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
222 |
fun metaeq sg lhs rhs = mk_meta_eq (prove_goalw_cterm [] |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
223 |
(cterm_of sg (HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs,rhs)))) |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
224 |
(K [simp_tac (HOL_basic_ss addsimps [cond_split_eta]) 1])); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
225 |
val sign = sign_of (the_context ()); |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
226 |
fun simproc name patstr = Simplifier.mk_simproc name |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
227 |
[Thm.read_cterm sign (patstr, HOLogic.termT)]; |
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
228 |
|
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
229 |
val beta_patstr = "split f z"; |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
230 |
val eta_patstr = "split f"; |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
231 |
fun beta_term_pat k i (Abs (_, _, t)) = beta_term_pat (k+1) i t |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
232 |
| beta_term_pat k i (t $ u) = Pair_pat k i (t $ u) orelse |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
233 |
(beta_term_pat k i t andalso beta_term_pat k i u) |
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
234 |
| beta_term_pat k i t = no_args k i t; |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
235 |
fun eta_term_pat k i (f $ arg) = no_args k i f andalso Pair_pat k i arg |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
236 |
| eta_term_pat _ _ _ = false; |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
237 |
fun subst arg k i (Abs (x, T, t)) = Abs (x, T, subst arg (k+1) i t) |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
238 |
| subst arg k i (t $ u) = if Pair_pat k i (t $ u) then incr_boundvars k arg |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
239 |
else (subst arg k i t $ subst arg k i u) |
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
240 |
| subst arg k i t = t; |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
241 |
fun beta_proc sg _ (s as Const ("split", _) $ Abs (_, _, t) $ arg) = |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
242 |
(case split_pat beta_term_pat 1 t of |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
243 |
Some (i,f) => Some (metaeq sg s (subst arg 0 i f)) |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
244 |
| None => None) |
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
245 |
| beta_proc _ _ _ = None; |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
246 |
fun eta_proc sg _ (s as Const ("split", _) $ Abs (_, _, t)) = |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
247 |
(case split_pat eta_term_pat 1 t of |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
248 |
Some (_,ft) => Some (metaeq sg s (let val (f $ arg) = ft in f end)) |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
249 |
| None => None) |
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
250 |
| eta_proc _ _ _ = None; |
5294 | 251 |
in |
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
252 |
val split_beta_proc = simproc "split_beta" beta_patstr beta_proc; |
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
253 |
val split_eta_proc = simproc "split_eta" eta_patstr eta_proc; |
5294 | 254 |
end; |
255 |
||
7495
affcfd2830b7
added theorems fst_eqD and snd_eqD, added split_beta_proc, new split_eta_proc
oheimb
parents:
7339
diff
changeset
|
256 |
Addsimprocs [split_beta_proc,split_eta_proc]; |
5294 | 257 |
|
7031 | 258 |
Goal "(%(x,y). P x y) z = P (fst z) (snd z)"; |
259 |
by (stac surjective_pairing 1 THEN rtac split 1); |
|
260 |
qed "split_beta"; |
|
4134 | 261 |
|
923 | 262 |
(*For use with split_tac and the simplifier*) |
5069 | 263 |
Goal "R (split c p) = (! x y. p = (x,y) --> R (c x y))"; |
923 | 264 |
by (stac surjective_pairing 1); |
265 |
by (stac split 1); |
|
2935 | 266 |
by (Blast_tac 1); |
4830 | 267 |
qed "split_split"; |
923 | 268 |
|
3568
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
269 |
(* could be done after split_tac has been speeded up significantly: |
4830 | 270 |
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
|
271 |
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
|
272 |
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
|
273 |
*) |
36ff1ab12021
Prod.ML: Added split_paired_EX and lots of comments about failed attempts to
nipkow
parents:
3429
diff
changeset
|
274 |
|
5069 | 275 |
Goal "R (split c p) = (~(? x y. p = (x,y) & (~R (c x y))))"; |
4830 | 276 |
by (stac split_split 1); |
4435 | 277 |
by (Simp_tac 1); |
278 |
qed "expand_split_asm"; |
|
279 |
||
923 | 280 |
(** split used as a logical connective or set former **) |
281 |
||
2935 | 282 |
(*These rules are for use with blast_tac. |
923 | 283 |
Could instead call simp_tac/asm_full_simp_tac using split as rewrite.*) |
284 |
||
5069 | 285 |
Goal "!!p. [| !!a b. p=(a,b) ==> c a b |] ==> split c p"; |
1552 | 286 |
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
|
287 |
by (Asm_simp_tac 1); |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
288 |
qed "splitI2"; |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
289 |
|
7958 | 290 |
Goal "!!p. [| !!a b. (a,b)=p ==> c a b x |] ==> split c p x"; |
291 |
by (split_all_tac 1); |
|
292 |
by (Asm_simp_tac 1); |
|
293 |
qed "splitI2'"; |
|
294 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
295 |
Goal "c a b ==> split c (a,b)"; |
1264 | 296 |
by (Asm_simp_tac 1); |
923 | 297 |
qed "splitI"; |
298 |
||
5316 | 299 |
val prems = Goalw [split_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
300 |
"[| split c p; !!x y. [| p = (x,y); c x y |] ==> Q |] ==> Q"; |
923 | 301 |
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1)); |
302 |
qed "splitE"; |
|
303 |
||
8157 | 304 |
val prems = Goalw [split_def] |
305 |
"[| split c p z; !!x y. [| p = (x,y); c x y z |] ==> Q |] ==> Q"; |
|
306 |
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1)); |
|
307 |
qed "splitE'"; |
|
308 |
||
9969 | 309 |
val major::prems = Goal |
7031 | 310 |
"[| Q (split P z); !!x y. [|z = (x, y); Q (P x y)|] ==> R \ |
311 |
\ |] ==> R"; |
|
312 |
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1)); |
|
313 |
by (rtac (split_beta RS subst) 1 THEN rtac major 1); |
|
314 |
qed "splitE2"; |
|
4134 | 315 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
316 |
Goal "split R (a,b) ==> R a b"; |
923 | 317 |
by (etac (split RS iffD1) 1); |
318 |
qed "splitD"; |
|
319 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
320 |
Goal "z: c a b ==> z: split c (a,b)"; |
1264 | 321 |
by (Asm_simp_tac 1); |
923 | 322 |
qed "mem_splitI"; |
323 |
||
5069 | 324 |
Goal "!!p. [| !!a b. p=(a,b) ==> z: c a b |] ==> z: split c p"; |
1552 | 325 |
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
|
326 |
by (Asm_simp_tac 1); |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
327 |
qed "mem_splitI2"; |
d0266c81a85e
Streamlined defs in Relation and added new intro/elim rules to do with
nipkow
parents:
1301
diff
changeset
|
328 |
|
5316 | 329 |
val prems = Goalw [split_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
330 |
"[| z: split c p; !!x y. [| p = (x,y); z: c x y |] ==> Q |] ==> Q"; |
923 | 331 |
by (REPEAT (resolve_tac (prems@[surjective_pairing]) 1)); |
332 |
qed "mem_splitE"; |
|
333 |
||
7958 | 334 |
AddSIs [splitI, splitI2, splitI2', mem_splitI, mem_splitI2]; |
8157 | 335 |
AddSEs [splitE, splitE', mem_splitE]; |
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
336 |
|
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
337 |
Goal "(%u. ? x y. u = (x, y) & P (x, y)) = P"; |
9020
1056cbbaeb29
added split_eta_SetCompr2 (also to simpset), generalized SetCompr_Sigma_eq
oheimb
parents:
8703
diff
changeset
|
338 |
by (rtac ext 1); |
1056cbbaeb29
added split_eta_SetCompr2 (also to simpset), generalized SetCompr_Sigma_eq
oheimb
parents:
8703
diff
changeset
|
339 |
by (Fast_tac 1); |
1056cbbaeb29
added split_eta_SetCompr2 (also to simpset), generalized SetCompr_Sigma_eq
oheimb
parents:
8703
diff
changeset
|
340 |
qed "split_eta_SetCompr"; |
1056cbbaeb29
added split_eta_SetCompr2 (also to simpset), generalized SetCompr_Sigma_eq
oheimb
parents:
8703
diff
changeset
|
341 |
Addsimps [split_eta_SetCompr]; |
1056cbbaeb29
added split_eta_SetCompr2 (also to simpset), generalized SetCompr_Sigma_eq
oheimb
parents:
8703
diff
changeset
|
342 |
|
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
343 |
Goal "(%u. ? x y. u = (x, y) & P x y) = split P"; |
9020
1056cbbaeb29
added split_eta_SetCompr2 (also to simpset), generalized SetCompr_Sigma_eq
oheimb
parents:
8703
diff
changeset
|
344 |
br ext 1; |
1056cbbaeb29
added split_eta_SetCompr2 (also to simpset), generalized SetCompr_Sigma_eq
oheimb
parents:
8703
diff
changeset
|
345 |
by (Fast_tac 1); |
1056cbbaeb29
added split_eta_SetCompr2 (also to simpset), generalized SetCompr_Sigma_eq
oheimb
parents:
8703
diff
changeset
|
346 |
qed "split_eta_SetCompr2"; |
1056cbbaeb29
added split_eta_SetCompr2 (also to simpset), generalized SetCompr_Sigma_eq
oheimb
parents:
8703
diff
changeset
|
347 |
Addsimps [split_eta_SetCompr2]; |
1056cbbaeb29
added split_eta_SetCompr2 (also to simpset), generalized SetCompr_Sigma_eq
oheimb
parents:
8703
diff
changeset
|
348 |
|
4534 | 349 |
(* allows simplifications of nested splits in case of independent predicates *) |
5069 | 350 |
Goal "(%(a,b). P & Q a b) = (%ab. P & split Q ab)"; |
4534 | 351 |
by (rtac ext 1); |
352 |
by (Blast_tac 1); |
|
353 |
qed "split_part"; |
|
354 |
Addsimps [split_part]; |
|
355 |
||
5069 | 356 |
Goal "(@(x',y'). x = x' & y = y') = (x,y)"; |
4534 | 357 |
by (Blast_tac 1); |
358 |
qed "Eps_split_eq"; |
|
359 |
Addsimps [Eps_split_eq]; |
|
360 |
(* |
|
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
361 |
the following would be slightly more general, |
4534 | 362 |
but cannot be used as rewrite rule: |
363 |
### Cannot add premise as rewrite rule because it contains (type) unknowns: |
|
364 |
### ?y = .x |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
365 |
Goal "[| P y; !!x. P x ==> x = y |] ==> (@(x',y). x = x' & P y) = (x,y)"; |
9969 | 366 |
by (rtac some_equality 1); |
4534 | 367 |
by ( Simp_tac 1); |
368 |
by (split_all_tac 1); |
|
369 |
by (Asm_full_simp_tac 1); |
|
370 |
qed "Eps_split_eq"; |
|
371 |
*) |
|
372 |
||
923 | 373 |
(*** prod_fun -- action of the product functor upon functions ***) |
374 |
||
5069 | 375 |
Goalw [prod_fun_def] "prod_fun f g (a,b) = (f(a),g(b))"; |
923 | 376 |
by (rtac split 1); |
377 |
qed "prod_fun"; |
|
4521 | 378 |
Addsimps [prod_fun]; |
923 | 379 |
|
5278 | 380 |
Goal "prod_fun (f1 o f2) (g1 o g2) = ((prod_fun f1 g1) o (prod_fun f2 g2))"; |
923 | 381 |
by (rtac ext 1); |
4828 | 382 |
by (pair_tac "x" 1); |
4521 | 383 |
by (Asm_simp_tac 1); |
923 | 384 |
qed "prod_fun_compose"; |
385 |
||
5069 | 386 |
Goal "prod_fun (%x. x) (%y. y) = (%z. z)"; |
923 | 387 |
by (rtac ext 1); |
4828 | 388 |
by (pair_tac "z" 1); |
4521 | 389 |
by (Asm_simp_tac 1); |
923 | 390 |
qed "prod_fun_ident"; |
4521 | 391 |
Addsimps [prod_fun_ident]; |
923 | 392 |
|
5316 | 393 |
Goal "(a,b):r ==> (f(a),g(b)) : (prod_fun f g)``r"; |
923 | 394 |
by (rtac image_eqI 1); |
395 |
by (rtac (prod_fun RS sym) 1); |
|
5316 | 396 |
by (assume_tac 1); |
923 | 397 |
qed "prod_fun_imageI"; |
398 |
||
5316 | 399 |
val major::prems = Goal |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
400 |
"[| c: (prod_fun f g)``r; !!x y. [| c=(f(x),g(y)); (x,y):r |] ==> P \ |
923 | 401 |
\ |] ==> P"; |
402 |
by (rtac (major RS imageE) 1); |
|
403 |
by (res_inst_tac [("p","x")] PairE 1); |
|
404 |
by (resolve_tac prems 1); |
|
2935 | 405 |
by (Blast_tac 2); |
4089 | 406 |
by (blast_tac (claset() addIs [prod_fun]) 1); |
923 | 407 |
qed "prod_fun_imageE"; |
408 |
||
5788 | 409 |
AddIs [prod_fun_imageI]; |
410 |
AddSEs [prod_fun_imageE]; |
|
411 |
||
4521 | 412 |
|
923 | 413 |
(*** Disjoint union of a family of sets - Sigma ***) |
414 |
||
7031 | 415 |
Goalw [Sigma_def] "[| a:A; b:B(a) |] ==> (a,b) : Sigma A B"; |
416 |
by (REPEAT (ares_tac [singletonI,UN_I] 1)); |
|
417 |
qed "SigmaI"; |
|
923 | 418 |
|
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
419 |
AddSIs [SigmaI]; |
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
420 |
|
923 | 421 |
(*The general elimination rule*) |
7031 | 422 |
val major::prems = Goalw [Sigma_def] |
923 | 423 |
"[| c: Sigma A B; \ |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
424 |
\ !!x y.[| x:A; y:B(x); c=(x,y) |] ==> P \ |
7031 | 425 |
\ |] ==> P"; |
426 |
by (cut_facts_tac [major] 1); |
|
427 |
by (REPEAT (eresolve_tac [UN_E, singletonE] 1 ORELSE ares_tac prems 1)) ; |
|
428 |
qed "SigmaE"; |
|
923 | 429 |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
430 |
(** Elimination of (a,b):A*B -- introduces no eigenvariables **) |
7007 | 431 |
|
432 |
Goal "(a,b) : Sigma A B ==> a : A"; |
|
433 |
by (etac SigmaE 1); |
|
434 |
by (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ; |
|
435 |
qed "SigmaD1"; |
|
923 | 436 |
|
7007 | 437 |
Goal "(a,b) : Sigma A B ==> b : B(a)"; |
438 |
by (etac SigmaE 1); |
|
439 |
by (REPEAT (eresolve_tac [asm_rl,Pair_inject,ssubst] 1)) ; |
|
440 |
qed "SigmaD2"; |
|
923 | 441 |
|
9969 | 442 |
val [major,minor]= Goal |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
923
diff
changeset
|
443 |
"[| (a,b) : Sigma A B; \ |
923 | 444 |
\ [| a:A; b:B(a) |] ==> P \ |
7007 | 445 |
\ |] ==> P"; |
446 |
by (rtac minor 1); |
|
447 |
by (rtac (major RS SigmaD1) 1); |
|
448 |
by (rtac (major RS SigmaD2) 1) ; |
|
449 |
qed "SigmaE2"; |
|
923 | 450 |
|
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
451 |
AddSEs [SigmaE2, SigmaE]; |
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
452 |
|
5316 | 453 |
val prems = Goal |
1642 | 454 |
"[| A<=C; !!x. x:A ==> B x <= D x |] ==> Sigma A B <= Sigma C D"; |
1515 | 455 |
by (cut_facts_tac prems 1); |
4089 | 456 |
by (blast_tac (claset() addIs (prems RL [subsetD])) 1); |
1515 | 457 |
qed "Sigma_mono"; |
458 |
||
7007 | 459 |
Goal "Sigma {} B = {}"; |
460 |
by (Blast_tac 1) ; |
|
461 |
qed "Sigma_empty1"; |
|
1618 | 462 |
|
8703 | 463 |
Goal "A <*> {} = {}"; |
7007 | 464 |
by (Blast_tac 1) ; |
465 |
qed "Sigma_empty2"; |
|
1618 | 466 |
|
8703 | 467 |
Addsimps [Sigma_empty1,Sigma_empty2]; |
468 |
||
469 |
Goal "UNIV <*> UNIV = UNIV"; |
|
470 |
by Auto_tac; |
|
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
471 |
qed "UNIV_Times_UNIV"; |
8703 | 472 |
Addsimps [UNIV_Times_UNIV]; |
473 |
||
474 |
Goal "- (UNIV <*> A) = UNIV <*> (-A)"; |
|
475 |
by Auto_tac; |
|
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
476 |
qed "Compl_Times_UNIV1"; |
8703 | 477 |
|
478 |
Goal "- (A <*> UNIV) = (-A) <*> UNIV"; |
|
479 |
by Auto_tac; |
|
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
480 |
qed "Compl_Times_UNIV2"; |
8703 | 481 |
|
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
482 |
Addsimps [Compl_Times_UNIV1, Compl_Times_UNIV2]; |
1618 | 483 |
|
5069 | 484 |
Goal "((a,b): Sigma A B) = (a:A & b:B(a))"; |
2935 | 485 |
by (Blast_tac 1); |
1618 | 486 |
qed "mem_Sigma_iff"; |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
487 |
AddIffs [mem_Sigma_iff]; |
1618 | 488 |
|
8703 | 489 |
Goal "x:C ==> (A <*> C <= B <*> C) = (A <= B)"; |
6016 | 490 |
by (Blast_tac 1); |
491 |
qed "Times_subset_cancel2"; |
|
492 |
||
8703 | 493 |
Goal "x:C ==> (A <*> C = B <*> C) = (A = B)"; |
6016 | 494 |
by (blast_tac (claset() addEs [equalityE]) 1); |
495 |
qed "Times_eq_cancel2"; |
|
496 |
||
9020
1056cbbaeb29
added split_eta_SetCompr2 (also to simpset), generalized SetCompr_Sigma_eq
oheimb
parents:
8703
diff
changeset
|
497 |
Goal "Collect (split (%x y. P x & Q x y)) = (SIGMA x:Collect P. Collect (Q x))"; |
8261 | 498 |
by (Fast_tac 1); |
499 |
qed "SetCompr_Sigma_eq"; |
|
5810 | 500 |
|
501 |
(*** Complex rules for Sigma ***) |
|
502 |
||
8703 | 503 |
Goal "{(a,b). P a & Q b} = Collect P <*> Collect Q"; |
7031 | 504 |
by (Blast_tac 1); |
505 |
qed "Collect_split"; |
|
506 |
||
4534 | 507 |
Addsimps [Collect_split]; |
1515 | 508 |
|
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
509 |
(*Suggested by Pierre Chartier*) |
8703 | 510 |
Goal "(UN (a,b):(A <*> B). E a <*> F b) = (UNION A E) <*> (UNION B F)"; |
2935 | 511 |
by (Blast_tac 1); |
6830
f8aed3706af7
renamed UNION_... to UN_... (to fit the convention)
paulson
parents:
6394
diff
changeset
|
512 |
qed "UN_Times_distrib"; |
2856
cdb908486a96
Reorganization of how classical rules are installed
paulson
parents:
2637
diff
changeset
|
513 |
|
6016 | 514 |
Goal "(ALL z: Sigma A B. P z) = (ALL x:A. ALL y: B x. P(x,y))"; |
5810 | 515 |
by (Fast_tac 1); |
6016 | 516 |
qed "split_paired_Ball_Sigma"; |
517 |
Addsimps [split_paired_Ball_Sigma]; |
|
5810 | 518 |
|
6016 | 519 |
Goal "(EX z: Sigma A B. P z) = (EX x:A. EX y: B x. P(x,y))"; |
5810 | 520 |
by (Fast_tac 1); |
6016 | 521 |
qed "split_paired_Bex_Sigma"; |
522 |
Addsimps [split_paired_Bex_Sigma]; |
|
5810 | 523 |
|
524 |
Goal "(SIGMA i:I Un J. C(i)) = (SIGMA i:I. C(i)) Un (SIGMA j:J. C(j))"; |
|
525 |
by (Blast_tac 1); |
|
526 |
qed "Sigma_Un_distrib1"; |
|
527 |
||
528 |
Goal "(SIGMA i:I. A(i) Un B(i)) = (SIGMA i:I. A(i)) Un (SIGMA i:I. B(i))"; |
|
529 |
by (Blast_tac 1); |
|
530 |
qed "Sigma_Un_distrib2"; |
|
531 |
||
532 |
Goal "(SIGMA i:I Int J. C(i)) = (SIGMA i:I. C(i)) Int (SIGMA j:J. C(j))"; |
|
533 |
by (Blast_tac 1); |
|
534 |
qed "Sigma_Int_distrib1"; |
|
535 |
||
536 |
Goal "(SIGMA i:I. A(i) Int B(i)) = (SIGMA i:I. A(i)) Int (SIGMA i:I. B(i))"; |
|
537 |
by (Blast_tac 1); |
|
538 |
qed "Sigma_Int_distrib2"; |
|
539 |
||
540 |
Goal "(SIGMA i:I - J. C(i)) = (SIGMA i:I. C(i)) - (SIGMA j:J. C(j))"; |
|
541 |
by (Blast_tac 1); |
|
542 |
qed "Sigma_Diff_distrib1"; |
|
543 |
||
544 |
Goal "(SIGMA i:I. A(i) - B(i)) = (SIGMA i:I. A(i)) - (SIGMA i:I. B(i))"; |
|
545 |
by (Blast_tac 1); |
|
546 |
qed "Sigma_Diff_distrib2"; |
|
547 |
||
6016 | 548 |
Goal "Sigma (Union X) B = (UN A:X. Sigma A B)"; |
549 |
by (Blast_tac 1); |
|
550 |
qed "Sigma_Union"; |
|
551 |
||
8255 | 552 |
(*Non-dependent versions are needed to avoid the need for higher-order |
553 |
matching, especially when the rules are re-oriented*) |
|
8703 | 554 |
Goal "(A Un B) <*> C = (A <*> C) Un (B <*> C)"; |
8255 | 555 |
by (Blast_tac 1); |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
556 |
qed "Times_Un_distrib1"; |
8255 | 557 |
|
8703 | 558 |
Goal "(A Int B) <*> C = (A <*> C) Int (B <*> C)"; |
8255 | 559 |
by (Blast_tac 1); |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
560 |
qed "Times_Int_distrib1"; |
8255 | 561 |
|
8703 | 562 |
Goal "(A - B) <*> C = (A <*> C) - (B <*> C)"; |
8255 | 563 |
by (Blast_tac 1); |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
564 |
qed "Times_Diff_distrib1"; |
5088
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
565 |
|
e4aa78d1312f
New rewrite unit_abs_eta_conv to compensate for unit_eq_proc
paulson
parents:
5083
diff
changeset
|
566 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
567 |
(*Attempts to remove occurrences of split, and pair-valued parameters*) |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
568 |
val remove_split = rewrite_rule [split RS eq_reflection] o |
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
569 |
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
|
570 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
571 |
local |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
572 |
|
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
573 |
(*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
|
574 |
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
|
575 |
of type S.*) |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
576 |
fun ap_split (Type ("*", [T1, T2])) T3 u = |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
577 |
HOLogic.split_const (T1, T2, T3) $ |
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
578 |
Abs("v", T1, |
2031 | 579 |
ap_split T2 T3 |
9359
a4b990838074
improved unit theory: unit_all_eq1, unit_all_eq2, split_all_tac;
wenzelm
parents:
9345
diff
changeset
|
580 |
((ap_split T1 (HOLogic.prodT_factors T2 ---> T3) (incr_boundvars 1 u)) $ |
2031 | 581 |
Bound 0)) |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
582 |
| ap_split T T3 u = u; |
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
583 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
584 |
(*Curries any Var of function type in the rule*) |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
585 |
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
|
586 |
let val T' = HOLogic.prodT_factors T1 ---> T2 |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
587 |
val newt = ap_split T1 T2 (Var (v, T')) |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
588 |
val cterm = Thm.cterm_of (#sign (rep_thm rl)) |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
589 |
in |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
590 |
instantiate ([], [(cterm t, cterm newt)]) rl |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
591 |
end |
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
592 |
| 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
|
593 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
594 |
in |
1746
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
595 |
|
5096
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
596 |
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
|
597 |
|
84b00be693b4
Moved most of the Prod_Syntax - stuff to HOLogic.
berghofe
parents:
5088
diff
changeset
|
598 |
(*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
|
599 |
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
|
600 |
|> standard; |
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
601 |
|
f0c6aabc6c02
Moved split_rule et al from ind_syntax.ML to Prod.ML.
nipkow
parents:
1727
diff
changeset
|
602 |
end; |