equal
deleted
inserted
replaced
193 fun atomize_thm thm = |
193 fun atomize_thm thm = |
194 let |
194 let |
195 val thm' = Thm.freezeT (forall_intr_vars thm) |
195 val thm' = Thm.freezeT (forall_intr_vars thm) |
196 val thm'' = ObjectLogic.atomize (cprop_of thm') |
196 val thm'' = ObjectLogic.atomize (cprop_of thm') |
197 in |
197 in |
198 @{thm Pure.equal_elim_rule1} OF [thm'', thm'] |
198 @{thm equal_elim_rule1} OF [thm'', thm'] |
199 end |
199 end |
200 *} |
200 *} |
201 |
201 |
202 ML {* atomize_thm @{thm list.induct} *} |
|
203 |
|
204 section {* infrastructure about id *} |
202 section {* infrastructure about id *} |
205 |
203 |
206 (* Need to have a meta-equality *) |
204 (* Need to have a meta-equality *) |
|
205 |
207 lemma id_def_sym: "(\<lambda>x. x) \<equiv> id" |
206 lemma id_def_sym: "(\<lambda>x. x) \<equiv> id" |
208 by (simp add: id_def) |
207 by (simp add: id_def) |
|
208 |
209 (* TODO: can be also obtained with: *) |
209 (* TODO: can be also obtained with: *) |
210 ML {* symmetric (eq_reflection OF @{thms id_def}) *} |
210 ML {* symmetric (eq_reflection OF @{thms id_def}) *} |
211 |
211 |
212 lemma prod_fun_id: "prod_fun id id \<equiv> id" |
212 lemma prod_fun_id: "prod_fun id id \<equiv> id" |
213 by (rule eq_reflection) (simp add: prod_fun_def) |
213 by (rule eq_reflection) (simp add: prod_fun_def) |
248 end |
248 end |
249 *} |
249 *} |
250 |
250 |
251 section {* Infrastructure about definitions *} |
251 section {* Infrastructure about definitions *} |
252 |
252 |
253 text {* expects atomized definition *} |
253 (* expects atomized definitions *) |
254 ML {* |
254 ML {* |
255 fun add_lower_defs_aux lthy thm = |
255 fun add_lower_defs_aux lthy thm = |
256 let |
256 let |
257 val e1 = @{thm fun_cong} OF [thm]; |
257 val e1 = @{thm fun_cong} OF [thm]; |
258 val f = eqsubst_thm lthy @{thms fun_map.simps} e1; |
258 val f = eqsubst_thm lthy @{thms fun_map.simps} e1; |
272 in |
272 in |
273 map Thm.varifyT defs_all |
273 map Thm.varifyT defs_all |
274 end |
274 end |
275 *} |
275 *} |
276 |
276 |
277 section {* infrastructure about collecting theorems for calling lifting *} |
277 section {* Infrastructure for collecting theorems for calling lifting *} |
278 |
278 |
279 ML {* |
279 ML {* |
280 fun lookup_quot_data lthy qty = |
280 fun lookup_quot_data lthy qty = |
281 let |
281 let |
282 val qty_name = fst (dest_Type qty) |
282 val qty_name = fst (dest_Type qty) |
314 in |
314 in |
315 map (fst o dest_Const o snd o dest_term) def_terms |
315 map (fst o dest_Const o snd o dest_term) def_terms |
316 end |
316 end |
317 *} |
317 *} |
318 |
318 |
319 |
|
320 |
|
321 section {* Regularization *} |
319 section {* Regularization *} |
322 |
320 |
323 |
|
324 ML {* |
|
325 (* |
321 (* |
326 Regularizing an rtrm means: |
322 Regularizing an rtrm means: |
327 - quantifiers over a type that needs lifting are replaced by |
323 - quantifiers over a type that needs lifting are replaced by |
328 bounded quantifiers, for example: |
324 bounded quantifiers, for example: |
329 \<forall>x. P \<Longrightarrow> \<forall>x \<in> (Respects R). P / All (Respects R) P |
325 \<forall>x. P \<Longrightarrow> \<forall>x \<in> (Respects R). P / All (Respects R) P |
340 |
336 |
341 example with more complicated types of A, B: |
337 example with more complicated types of A, B: |
342 A = B \<Longrightarrow> (op = \<Longrightarrow> op \<approx>) A B |
338 A = B \<Longrightarrow> (op = \<Longrightarrow> op \<approx>) A B |
343 *) |
339 *) |
344 |
340 |
345 |
341 ML {* |
346 (* builds the relation that is the argument of respects *) |
342 (* builds the relation that is the argument of respects *) |
347 fun mk_resp_arg lthy (rty, qty) = |
343 fun mk_resp_arg lthy (rty, qty) = |
348 let |
344 let |
349 val thy = ProofContext.theory_of lthy |
345 val thy = ProofContext.theory_of lthy |
350 in |
346 in |
379 val mk_babs = Const (@{const_name "Babs"}, dummyT) |
375 val mk_babs = Const (@{const_name "Babs"}, dummyT) |
380 val mk_ball = Const (@{const_name "Ball"}, dummyT) |
376 val mk_ball = Const (@{const_name "Ball"}, dummyT) |
381 val mk_bex = Const (@{const_name "Bex"}, dummyT) |
377 val mk_bex = Const (@{const_name "Bex"}, dummyT) |
382 val mk_resp = Const (@{const_name Respects}, dummyT) |
378 val mk_resp = Const (@{const_name Respects}, dummyT) |
383 *} |
379 *} |
384 |
|
385 |
380 |
386 ML {* |
381 ML {* |
387 (* - applies f to the subterm of an abstraction, *) |
382 (* - applies f to the subterm of an abstraction, *) |
388 (* otherwise to the given term, *) |
383 (* otherwise to the given term, *) |
389 (* - used by REGULARIZE, therefore abstracted *) |
384 (* - used by REGULARIZE, therefore abstracted *) |
456 else rtrm (* FIXME: check correspondence according to definitions *) |
451 else rtrm (* FIXME: check correspondence according to definitions *) |
457 | (rt, qt) => |
452 | (rt, qt) => |
458 raise (LIFT_MATCH "regularize (default)") |
453 raise (LIFT_MATCH "regularize (default)") |
459 *} |
454 *} |
460 |
455 |
461 ML {* |
|
462 fun mk_REGULARIZE_goal lthy rtrm qtrm = |
|
463 Logic.mk_implies (rtrm, Syntax.check_term lthy (REGULARIZE_trm lthy rtrm qtrm)) |
|
464 *} |
|
465 |
|
466 (* |
456 (* |
467 To prove that the raw theorem implies the regularised one, |
457 To prove that the raw theorem implies the regularised one, |
468 we try in order: |
458 we try in order: |
469 |
459 |
470 - Reflexivity of the relation |
460 - Reflexivity of the relation |
519 DT ctxt "7" (rtac @{thm impI} THEN' (asm_full_simp_tac HOL_ss) THEN' rtac rel_refl), |
509 DT ctxt "7" (rtac @{thm impI} THEN' (asm_full_simp_tac HOL_ss) THEN' rtac rel_refl), |
520 DT ctxt "8" (rtac @{thm RIGHT_RES_FORALL_REGULAR}) |
510 DT ctxt "8" (rtac @{thm RIGHT_RES_FORALL_REGULAR}) |
521 ]); |
511 ]); |
522 *} |
512 *} |
523 |
513 |
524 lemma move_forall: "(\<And>y. (\<forall>x\<in>P. A x y) \<longrightarrow> (\<forall>x. B x y)) \<Longrightarrow> ((\<forall>x\<in>P. \<forall>y. A x y) \<longrightarrow> (\<forall>x. \<forall>y. B x y))" |
514 lemma move_forall: |
|
515 "(\<And>y. (\<forall>x\<in>P. A x y) \<longrightarrow> (\<forall>x. B x y)) \<Longrightarrow> ((\<forall>x\<in>P. \<forall>y. A x y) \<longrightarrow> (\<forall>x. \<forall>y. B x y))" |
525 by auto |
516 by auto |
526 |
517 |
527 lemma move_exists: "((\<exists>y. \<exists>x. A x y) \<longrightarrow> (\<exists>y. \<exists>x\<in>P. B x y)) \<Longrightarrow> ((\<exists>x. \<exists>y. A x y) \<longrightarrow> (\<exists>x\<in>P. \<exists>y. B x y))" |
518 lemma move_exists: |
|
519 "((\<exists>y. \<exists>x. A x y) \<longrightarrow> (\<exists>y. \<exists>x\<in>P. B x y)) \<Longrightarrow> ((\<exists>x. \<exists>y. A x y) \<longrightarrow> (\<exists>x\<in>P. \<exists>y. B x y))" |
528 by auto |
520 by auto |
529 |
521 |
530 lemma [mono]: "(\<And>x. P x \<longrightarrow> Q x) \<Longrightarrow> (Ex P) \<longrightarrow> (Ex Q)" |
522 lemma [mono]: |
|
523 "(\<And>x. P x \<longrightarrow> Q x) \<Longrightarrow> (Ex P) \<longrightarrow> (Ex Q)" |
531 by blast |
524 by blast |
532 |
525 |
533 lemma [mono]: "P \<longrightarrow> Q \<Longrightarrow> \<not>Q \<longrightarrow> \<not>P" |
526 lemma [mono]: "P \<longrightarrow> Q \<Longrightarrow> \<not>Q \<longrightarrow> \<not>P" |
534 by auto |
527 by auto |
535 |
528 |
691 | _ => raise (LIFT_MATCH "injection") |
684 | _ => raise (LIFT_MATCH "injection") |
692 end |
685 end |
693 end |
686 end |
694 *} |
687 *} |
695 |
688 |
696 ML {* |
689 section {* RepAbs Injection Tactic *} |
697 fun mk_inj_REPABS_goal lthy (rtrm, qtrm) = |
|
698 Logic.mk_equals (rtrm, Syntax.check_term lthy (inj_REPABS lthy (rtrm, qtrm))) |
|
699 *} |
|
700 |
|
701 section {* RepAbs injection tactic *} |
|
702 (* |
690 (* |
703 To prove that the regularised theorem implies the abs/rep injected, we first |
691 To prove that the regularised theorem implies the abs/rep injected, we first |
704 atomize it and then try: |
692 atomize it and then try: |
705 |
693 |
706 1) theorems 'trans2' from the appropriate QUOT_TYPE |
694 1) theorems 'trans2' from the appropriate QUOT_TYPE |
834 ball_rsp_tac ctxt, |
822 ball_rsp_tac ctxt, |
835 rtac @{thm RES_EXISTS_RSP}, |
823 rtac @{thm RES_EXISTS_RSP}, |
836 bex_rsp_tac ctxt, |
824 bex_rsp_tac ctxt, |
837 FIRST' (map rtac rsp_thms), |
825 FIRST' (map rtac rsp_thms), |
838 rtac refl, |
826 rtac refl, |
839 (instantiate_tac @{thm REP_ABS_RSP(1)} ctxt THEN' (RANGE [SOLVES' (quotient_tac quot_thm)])), |
827 (instantiate_tac @{thm REP_ABS_RSP(1)} ctxt THEN' |
840 (APPLY_RSP_TAC rty ctxt THEN' (RANGE [SOLVES' (quotient_tac quot_thm), SOLVES' (quotient_tac quot_thm)])), |
828 (RANGE [SOLVES' (quotient_tac quot_thm)])), |
|
829 (APPLY_RSP_TAC rty ctxt THEN' |
|
830 (RANGE [SOLVES' (quotient_tac quot_thm), SOLVES' (quotient_tac quot_thm)])), |
841 Cong_Tac.cong_tac @{thm cong}, |
831 Cong_Tac.cong_tac @{thm cong}, |
842 rtac @{thm ext}, |
832 rtac @{thm ext}, |
843 rtac reflex_thm, |
833 rtac reflex_thm, |
844 atac, |
834 atac, |
845 SOLVES' (simp_tac (HOL_ss addsimps @{thms FUN_REL.simps})), |
835 SOLVES' (simp_tac (HOL_ss addsimps @{thms FUN_REL.simps})), |
962 fun allex_prs_tac lthy quot = |
952 fun allex_prs_tac lthy quot = |
963 (EqSubst.eqsubst_tac lthy [0] @{thms FORALL_PRS[symmetric] EXISTS_PRS[symmetric]}) |
953 (EqSubst.eqsubst_tac lthy [0] @{thms FORALL_PRS[symmetric] EXISTS_PRS[symmetric]}) |
964 THEN' (quotient_tac quot); |
954 THEN' (quotient_tac quot); |
965 *} |
955 *} |
966 |
956 |
967 ML {* |
|
968 let |
|
969 val parser = Args.context -- Scan.lift Args.name_source |
|
970 fun term_pat (ctxt, str) = |
|
971 str |> ProofContext.read_term_pattern ctxt |
|
972 |> ML_Syntax.print_term |
|
973 |> ML_Syntax.atomic |
|
974 in |
|
975 ML_Antiquote.inline "term_pat" (parser >> term_pat) |
|
976 end |
|
977 *} |
|
978 |
|
979 ML {* |
957 ML {* |
980 fun prep_trm thy (x, (T, t)) = |
958 fun prep_trm thy (x, (T, t)) = |
981 (cterm_of thy (Var (x, T)), cterm_of thy t) |
959 (cterm_of thy (Var (x, T)), cterm_of thy t) |
982 |
960 |
983 fun prep_ty thy (x, (S, ty)) = |
961 fun prep_ty thy (x, (S, ty)) = |
1061 TRY o REPEAT_ALL_NEW (EqSubst.eqsubst_tac lthy [0] lower), |
1039 TRY o REPEAT_ALL_NEW (EqSubst.eqsubst_tac lthy [0] lower), |
1062 simp_tac (HOL_ss addsimps [reps_same])] |
1040 simp_tac (HOL_ss addsimps [reps_same])] |
1063 end |
1041 end |
1064 *} |
1042 *} |
1065 |
1043 |
1066 (* Genralisation of free variables in a goal *) |
1044 section {* Genralisation of free variables in a goal *} |
1067 |
1045 |
1068 ML {* |
1046 ML {* |
1069 fun inst_spec ctrm = |
1047 fun inst_spec ctrm = |
1070 let |
1048 let |
1071 val cty = ctyp_of_term ctrm |
1049 val cty = ctyp_of_term ctrm |
1173 let |
1151 let |
1174 val rthm' = atomize_thm rthm |
1152 val rthm' = atomize_thm rthm |
1175 val rule = procedure_inst context (prop_of rthm') (term_of concl) |
1153 val rule = procedure_inst context (prop_of rthm') (term_of concl) |
1176 val aps = find_aps (prop_of rthm') (term_of concl) |
1154 val aps = find_aps (prop_of rthm') (term_of concl) |
1177 in |
1155 in |
1178 rtac rule THEN' RANGE [ |
1156 rtac rule THEN' |
1179 rtac rthm', |
1157 RANGE [rtac rthm', |
1180 regularize_tac lthy [rel_eqv] rel_refl, |
1158 regularize_tac lthy [rel_eqv] rel_refl, |
1181 REPEAT_ALL_NEW (r_mk_comb_tac lthy rty quot rel_refl trans2 rsp_thms), |
1159 REPEAT_ALL_NEW (r_mk_comb_tac lthy rty quot rel_refl trans2 rsp_thms), |
1182 clean_tac lthy quot defs reps_same absrep aps |
1160 clean_tac lthy quot defs reps_same absrep aps] |
1183 ] |
|
1184 end 1) lthy |
1161 end 1) lthy |
1185 *} |
1162 *} |
1186 |
1163 |
1187 end |
1164 end |
1188 |
1165 |