89 map_prod_simp mem_Collect_eq prod_set_simps map_sum.simps sum_set_simps}; |
89 map_prod_simp mem_Collect_eq prod_set_simps map_sum.simps sum_set_simps}; |
90 val sumprod_thms_set = @{thms UN_simps(10) image_iff} @ basic_sumprod_thms_set; |
90 val sumprod_thms_set = @{thms UN_simps(10) image_iff} @ basic_sumprod_thms_set; |
91 |
91 |
92 fun is_def_looping def = |
92 fun is_def_looping def = |
93 (case Thm.prop_of def of |
93 (case Thm.prop_of def of |
94 Const (@{const_name Pure.eq}, _) $ lhs $ rhs => Term.exists_subterm (curry (op aconv) lhs) rhs |
94 Const (\<^const_name>\<open>Pure.eq\<close>, _) $ lhs $ rhs => Term.exists_subterm (curry (op aconv) lhs) rhs |
95 | _ => false); |
95 | _ => false); |
96 |
96 |
97 fun hhf_concl_conv cv ctxt ct = |
97 fun hhf_concl_conv cv ctxt ct = |
98 (case Thm.term_of ct of |
98 (case Thm.term_of ct of |
99 Const (@{const_name Pure.all}, _) $ Abs _ => |
99 Const (\<^const_name>\<open>Pure.all\<close>, _) $ Abs _ => |
100 Conv.arg_conv (Conv.abs_conv (hhf_concl_conv cv o snd) ctxt) ct |
100 Conv.arg_conv (Conv.abs_conv (hhf_concl_conv cv o snd) ctxt) ct |
101 | _ => Conv.concl_conv ~1 cv ct); |
101 | _ => Conv.concl_conv ~1 cv ct); |
102 |
102 |
103 fun co_induct_inst_as_projs ctxt k thm = |
103 fun co_induct_inst_as_projs ctxt k thm = |
104 let |
104 let |
105 val fs = Term.add_vars (Thm.prop_of thm) [] |
105 val fs = Term.add_vars (Thm.prop_of thm) [] |
106 |> filter (fn (_, Type (@{type_name fun}, [_, T'])) => T' <> HOLogic.boolT | _ => false); |
106 |> filter (fn (_, Type (\<^type_name>\<open>fun\<close>, [_, T'])) => T' <> HOLogic.boolT | _ => false); |
107 fun mk_inst (xi, T) = (xi, Thm.cterm_of ctxt (mk_proj T (num_binder_types T) k)); |
107 fun mk_inst (xi, T) = (xi, Thm.cterm_of ctxt (mk_proj T (num_binder_types T) k)); |
108 in |
108 in |
109 infer_instantiate ctxt (map mk_inst fs) thm |
109 infer_instantiate ctxt (map mk_inst fs) thm |
110 end; |
110 end; |
111 |
111 |
191 rel_eqs = |
191 rel_eqs = |
192 let |
192 let |
193 val ctor_rec_transfers' = |
193 val ctor_rec_transfers' = |
194 map (infer_instantiate' ctxt (map SOME (passives @ actives))) ctor_rec_transfers; |
194 map (infer_instantiate' ctxt (map SOME (passives @ actives))) ctor_rec_transfers; |
195 val total_n = Integer.sum ns; |
195 val total_n = Integer.sum ns; |
196 val True = @{term True}; |
196 val True = \<^term>\<open>True\<close>; |
197 in |
197 in |
198 HEADGOAL Goal.conjunction_tac THEN |
198 HEADGOAL Goal.conjunction_tac THEN |
199 EVERY (map (fn ctor_rec_transfer => |
199 EVERY (map (fn ctor_rec_transfer => |
200 REPEAT_DETERM (HEADGOAL (rtac ctxt rel_funI)) THEN |
200 REPEAT_DETERM (HEADGOAL (rtac ctxt rel_funI)) THEN |
201 unfold_thms_tac ctxt rec_defs THEN |
201 unfold_thms_tac ctxt rec_defs THEN |
440 map (fn thm => thm RS eqFalseI) (distincts @ rel_distincts) @ |
440 map (fn thm => thm RS eqFalseI) (distincts @ rel_distincts) @ |
441 map (fn thm => thm RS eqTrueI) rel_injects) THEN |
441 map (fn thm => thm RS eqTrueI) rel_injects) THEN |
442 TRYALL (assume_tac ctxt ORELSE' etac ctxt FalseE ORELSE' |
442 TRYALL (assume_tac ctxt ORELSE' etac ctxt FalseE ORELSE' |
443 (REPEAT_DETERM o dtac ctxt meta_spec THEN' |
443 (REPEAT_DETERM o dtac ctxt meta_spec THEN' |
444 TRY o filter_prems_tac ctxt |
444 TRY o filter_prems_tac ctxt |
445 (forall (curry (op <>) (HOLogic.mk_Trueprop @{term False})) o Logic.strip_imp_prems) THEN' |
445 (forall (curry (op <>) (HOLogic.mk_Trueprop \<^term>\<open>False\<close>)) o Logic.strip_imp_prems) THEN' |
446 REPEAT_DETERM o (dtac ctxt meta_mp THEN' rtac ctxt refl) THEN' |
446 REPEAT_DETERM o (dtac ctxt meta_mp THEN' rtac ctxt refl) THEN' |
447 (assume_tac ctxt ORELSE' Goal.assume_rule_tac ctxt))); |
447 (assume_tac ctxt ORELSE' Goal.assume_rule_tac ctxt))); |
448 |
448 |
449 fun mk_rel_coinduct0_tac ctxt dtor_rel_coinduct cts assms exhausts discss selss ctor_defss |
449 fun mk_rel_coinduct0_tac ctxt dtor_rel_coinduct cts assms exhausts discss selss ctor_defss |
450 dtor_ctors ctor_injects abs_injects rel_pre_defs abs_inverses nesting_rel_eqs = |
450 dtor_ctors ctor_injects abs_injects rel_pre_defs abs_inverses nesting_rel_eqs = |