307 val frees = rev (map Free params'); |
307 val frees = rev (map Free params'); |
308 val concl = subst_bounds (frees, Logic.strip_assums_concl rule); |
308 val concl = subst_bounds (frees, Logic.strip_assums_concl rule); |
309 val prems = map (curry subst_bounds frees) (Logic.strip_assums_hyp rule); |
309 val prems = map (curry subst_bounds frees) (Logic.strip_assums_hyp rule); |
310 val rule' = Logic.list_implies (prems, concl); |
310 val rule' = Logic.list_implies (prems, concl); |
311 val aprems = map (atomize_term (Proof_Context.theory_of ctxt)) prems; |
311 val aprems = map (atomize_term (Proof_Context.theory_of ctxt)) prems; |
312 val arule = list_all_free (params', Logic.list_implies (aprems, concl)); |
312 val arule = fold_rev (Logic.all o Free) params' (Logic.list_implies (aprems, concl)); |
313 |
313 |
314 fun check_ind err t = |
314 fun check_ind err t = |
315 (case dest_predicate cs params t of |
315 (case dest_predicate cs params t of |
316 NONE => err (bad_app ^ |
316 NONE => err (bad_app ^ |
317 commas (map (Syntax.string_of_term ctxt) params)) |
317 commas (map (Syntax.string_of_term ctxt) params)) |
668 | (t, _) => t :: prems); |
668 | (t, _) => t :: prems); |
669 |
669 |
670 val SOME (_, i, ys, _) = |
670 val SOME (_, i, ys, _) = |
671 dest_predicate cs params (HOLogic.dest_Trueprop (Logic.strip_assums_concl r)); |
671 dest_predicate cs params (HOLogic.dest_Trueprop (Logic.strip_assums_concl r)); |
672 in |
672 in |
673 list_all_free (Logic.strip_params r, |
673 fold_rev (Logic.all o Free) (Logic.strip_params r) |
674 Logic.list_implies (map HOLogic.mk_Trueprop (fold_rev mk_prem |
674 (Logic.list_implies (map HOLogic.mk_Trueprop (fold_rev mk_prem |
675 (map HOLogic.dest_Trueprop (Logic.strip_assums_hyp r)) []), |
675 (map HOLogic.dest_Trueprop (Logic.strip_assums_hyp r)) []), |
676 HOLogic.mk_Trueprop (list_comb (nth preds i, ys)))) |
676 HOLogic.mk_Trueprop (list_comb (nth preds i, ys)))) |
677 end; |
677 end; |
678 |
678 |
679 val ind_prems = map mk_ind_prem intr_ts; |
679 val ind_prems = map mk_ind_prem intr_ts; |
1014 val (_, ctxt2) = lthy |> Variable.add_fixes (map (Binding.name_of o fst o fst) cnames_syn'); |
1014 val (_, ctxt2) = lthy |> Variable.add_fixes (map (Binding.name_of o fst o fst) cnames_syn'); |
1015 val _ = map (fn abbr => Local_Defs.fixed_abbrev abbr ctxt2) abbrevs; |
1015 val _ = map (fn abbr => Local_Defs.fixed_abbrev abbr ctxt2) abbrevs; |
1016 val ctxt3 = ctxt2 |> fold (snd oo Local_Defs.fixed_abbrev) abbrevs; |
1016 val ctxt3 = ctxt2 |> fold (snd oo Local_Defs.fixed_abbrev) abbrevs; |
1017 val expand = Assumption.export_term ctxt3 lthy #> Proof_Context.cert_term lthy; |
1017 val expand = Assumption.export_term ctxt3 lthy #> Proof_Context.cert_term lthy; |
1018 |
1018 |
1019 fun close_rule r = list_all_free (rev (fold_aterms |
1019 fun close_rule r = |
1020 (fn t as Free (v as (s, _)) => |
1020 fold (Logic.all o Free) (fold_aterms |
1021 if Variable.is_fixed ctxt1 s orelse |
1021 (fn t as Free (v as (s, _)) => |
1022 member (op =) ps t then I else insert (op =) v |
1022 if Variable.is_fixed ctxt1 s orelse |
1023 | _ => I) r []), r); |
1023 member (op =) ps t then I else insert (op =) v |
|
1024 | _ => I) r []) r; |
1024 |
1025 |
1025 val intros = map (apsnd (Syntax.check_term lthy #> close_rule #> expand)) pre_intros; |
1026 val intros = map (apsnd (Syntax.check_term lthy #> close_rule #> expand)) pre_intros; |
1026 val preds = map (fn ((c, _), mx) => (c, mx)) cnames_syn'; |
1027 val preds = map (fn ((c, _), mx) => (c, mx)) cnames_syn'; |
1027 in |
1028 in |
1028 lthy |
1029 lthy |