src/Pure/Isar/obtain.ML
changeset 31794 71af1fd6a5e4
parent 30763 6976521b4263
child 32091 30e2ffbba718
equal deleted inserted replaced
31793:7c10b13d49fe 31794:71af1fd6a5e4
    77 
    77 
    78     val _ = eliminate_term fix_ctxt xs (Thm.full_prop_of thm);
    78     val _ = eliminate_term fix_ctxt xs (Thm.full_prop_of thm);
    79     val _ = ObjectLogic.is_judgment thy (Thm.concl_of thm) orelse
    79     val _ = ObjectLogic.is_judgment thy (Thm.concl_of thm) orelse
    80       error "Conclusion in obtained context must be object-logic judgment";
    80       error "Conclusion in obtained context must be object-logic judgment";
    81 
    81 
    82     val ((_, [thm']), ctxt') = Variable.import_thms true [thm] fix_ctxt;
    82     val ((_, [thm']), ctxt') = Variable.import true [thm] fix_ctxt;
    83     val prems = Drule.strip_imp_prems (#prop (Thm.crep_thm thm'));
    83     val prems = Drule.strip_imp_prems (#prop (Thm.crep_thm thm'));
    84   in
    84   in
    85     ((Drule.implies_elim_list thm' (map Thm.assume prems)
    85     ((Drule.implies_elim_list thm' (map Thm.assume prems)
    86         |> Drule.implies_intr_list (map Drule.norm_hhf_cterm As)
    86         |> Drule.implies_intr_list (map Drule.norm_hhf_cterm As)
    87         |> Drule.forall_intr_list xs)
    87         |> Drule.forall_intr_list xs)
   194       (case SINGLE (Method.insert_tac facts 1 THEN tac thesis_ctxt) (Goal.init (cert thesis)) of
   194       (case SINGLE (Method.insert_tac facts 1 THEN tac thesis_ctxt) (Goal.init (cert thesis)) of
   195         NONE => raise THM ("Obtain.result: tactic failed", 0, facts)
   195         NONE => raise THM ("Obtain.result: tactic failed", 0, facts)
   196       | SOME th => check_result ctxt thesis (MetaSimplifier.norm_hhf (Goal.conclude th)));
   196       | SOME th => check_result ctxt thesis (MetaSimplifier.norm_hhf (Goal.conclude th)));
   197 
   197 
   198     val closed_rule = Thm.forall_intr (cert (Free thesis_var)) rule;
   198     val closed_rule = Thm.forall_intr (cert (Free thesis_var)) rule;
   199     val ((_, [rule']), ctxt') = Variable.import_thms false [closed_rule] ctxt;
   199     val ((_, [rule']), ctxt') = Variable.import false [closed_rule] ctxt;
   200     val obtain_rule = Thm.forall_elim (cert (Logic.varify (Free thesis_var))) rule';
   200     val obtain_rule = Thm.forall_elim (cert (Logic.varify (Free thesis_var))) rule';
   201     val ((params, stmt), fix_ctxt) = Variable.focus (Thm.cprem_of obtain_rule 1) ctxt';
   201     val ((params, stmt), fix_ctxt) = Variable.focus (Thm.cprem_of obtain_rule 1) ctxt';
   202     val (prems, ctxt'') =
   202     val (prems, ctxt'') =
   203       Assumption.add_assms (obtain_export fix_ctxt obtain_rule params)
   203       Assumption.add_assms (obtain_export fix_ctxt obtain_rule params)
   204         (Drule.strip_imp_prems stmt) fix_ctxt;
   204         (Drule.strip_imp_prems stmt) fix_ctxt;
   247       |> map (TVar #> (fn T => (certT T, certT (norm_type T))));
   247       |> map (TVar #> (fn T => (certT T, certT (norm_type T))));
   248     val closed_rule = rule
   248     val closed_rule = rule
   249       |> Thm.forall_intr (cert (Free thesis_var))
   249       |> Thm.forall_intr (cert (Free thesis_var))
   250       |> Thm.instantiate (instT, []);
   250       |> Thm.instantiate (instT, []);
   251 
   251 
   252     val ((_, rule' :: terms'), ctxt') = Variable.import_thms false (closed_rule :: terms) ctxt;
   252     val ((_, rule' :: terms'), ctxt') = Variable.import false (closed_rule :: terms) ctxt;
   253     val vars' =
   253     val vars' =
   254       map (dest_Free o Thm.term_of o Drule.dest_term) terms' ~~
   254       map (dest_Free o Thm.term_of o Drule.dest_term) terms' ~~
   255       (map snd vars @ replicate (length ys) NoSyn);
   255       (map snd vars @ replicate (length ys) NoSyn);
   256     val rule'' = Thm.forall_elim (cert (Logic.varify (Free thesis_var))) rule';
   256     val rule'' = Thm.forall_elim (cert (Logic.varify (Free thesis_var))) rule';
   257   in ((vars', rule''), ctxt') end;
   257   in ((vars', rule''), ctxt') end;