165 (fn [major]=> |
165 (fn [major]=> |
166 [ (rtac (major RS ex1E) 1), |
166 [ (rtac (major RS ex1E) 1), |
167 (resolve_tac [major RS the_equality2 RS ssubst] 1), |
167 (resolve_tac [major RS the_equality2 RS ssubst] 1), |
168 (REPEAT (assume_tac 1)) ]); |
168 (REPEAT (assume_tac 1)) ]); |
169 |
169 |
170 val the_cong = prove_goalw ZF.thy [the_def] |
|
171 "[| !!y. P(y) <-> Q(y) |] ==> (THE x. P(x)) = (THE x. Q(x))" |
|
172 (fn prems=> [ (prove_cong_tac (prems@[Replace_cong]) 1) ]); |
|
173 |
|
174 |
170 |
175 (*** if -- a conditional expression for formulae ***) |
171 (*** if -- a conditional expression for formulae ***) |
176 |
172 |
177 goalw ZF.thy [if_def] "if(True,a,b) = a"; |
173 goalw ZF.thy [if_def] "if(True,a,b) = a"; |
178 by (fast_tac (lemmas_cs addIs [the_equality]) 1); |
174 by (fast_tac (lemmas_cs addIs [the_equality]) 1); |
180 |
176 |
181 goalw ZF.thy [if_def] "if(False,a,b) = b"; |
177 goalw ZF.thy [if_def] "if(False,a,b) = b"; |
182 by (fast_tac (lemmas_cs addIs [the_equality]) 1); |
178 by (fast_tac (lemmas_cs addIs [the_equality]) 1); |
183 val if_false = result(); |
179 val if_false = result(); |
184 |
180 |
|
181 (*Never use with case splitting, or if P is known to be true or false*) |
185 val prems = goalw ZF.thy [if_def] |
182 val prems = goalw ZF.thy [if_def] |
186 "[| P<->Q; a=c; b=d |] ==> if(P,a,b) = if(Q,c,d)"; |
183 "[| P<->Q; Q ==> a=c; ~Q ==> b=d |] ==> if(P,a,b) = if(Q,c,d)"; |
187 by (REPEAT (resolve_tac (prems@[refl,the_cong]@FOL_congs) 1)); |
184 by (simp_tac (FOL_ss addsimps prems addcongs [conj_cong]) 1); |
188 val if_cong = result(); |
185 val if_cong = result(); |
189 |
186 |
190 (*Not needed for rewriting, since P would rewrite to True anyway*) |
187 (*Not needed for rewriting, since P would rewrite to True anyway*) |
191 val prems = goalw ZF.thy [if_def] "P ==> if(P,a,b) = a"; |
188 goalw ZF.thy [if_def] "!!P. P ==> if(P,a,b) = a"; |
192 by (cut_facts_tac prems 1); |
|
193 by (fast_tac (lemmas_cs addSIs [the_equality]) 1); |
189 by (fast_tac (lemmas_cs addSIs [the_equality]) 1); |
194 val if_P = result(); |
190 val if_P = result(); |
195 |
191 |
196 (*Not needed for rewriting, since P would rewrite to False anyway*) |
192 (*Not needed for rewriting, since P would rewrite to False anyway*) |
197 val prems = goalw ZF.thy [if_def] "~P ==> if(P,a,b) = b"; |
193 goalw ZF.thy [if_def] "!!P. ~P ==> if(P,a,b) = b"; |
198 by (cut_facts_tac prems 1); |
|
199 by (fast_tac (lemmas_cs addSIs [the_equality]) 1); |
194 by (fast_tac (lemmas_cs addSIs [the_equality]) 1); |
200 val if_not_P = result(); |
195 val if_not_P = result(); |
201 |
196 |
202 val if_ss = |
197 val if_ss = FOL_ss addsimps [if_true,if_false]; |
203 FOL_ss addcongs (if_cong :: mk_typed_congs ZF.thy [("P", "i=>o")] |
|
204 @ basic_ZF_congs) |
|
205 addrews [if_true,if_false]; |
|
206 |
198 |
207 val expand_if = prove_goal ZF.thy |
199 val expand_if = prove_goal ZF.thy |
208 "P(if(Q,x,y)) <-> ((Q --> P(x)) & (~Q --> P(y)))" |
200 "P(if(Q,x,y)) <-> ((Q --> P(x)) & (~Q --> P(y)))" |
209 (fn _=> [ (res_inst_tac [("Q","Q")] (excluded_middle RS disjE) 1), |
201 (fn _=> [ (res_inst_tac [("Q","Q")] (excluded_middle RS disjE) 1), |
210 (ASM_SIMP_TAC if_ss 1), |
202 (asm_simp_tac if_ss 1), |
211 (ASM_SIMP_TAC if_ss 1) ]); |
203 (asm_simp_tac if_ss 1) ]); |
212 |
204 |
213 val prems = goal ZF.thy |
205 val prems = goal ZF.thy |
214 "[| P ==> a: A; ~P ==> b: A |] ==> if(P,a,b): A"; |
206 "[| P ==> a: A; ~P ==> b: A |] ==> if(P,a,b): A"; |
215 by (res_inst_tac [("Q","P")] (excluded_middle RS disjE) 1); |
207 by (res_inst_tac [("Q","P")] (excluded_middle RS disjE) 1); |
216 by (ALLGOALS (ASM_SIMP_TAC (if_ss addrews prems))); |
208 by (ALLGOALS (asm_simp_tac (if_ss addsimps prems))); |
217 val if_type = result(); |
209 val if_type = result(); |
218 |
210 |
219 |
211 |
220 (*** Foundation lemmas ***) |
212 (*** Foundation lemmas ***) |
221 |
213 |