src/Pure/Isar/proof_display.ML
changeset 76081 730638d4e37a
parent 76079 47413d778c5f
child 76095 7cac5565e79b
equal deleted inserted replaced
76080:ae89a502b6fa 76081:730638d4e37a
   280           val prts =
   280           val prts =
   281             ((fold o fold) Term.add_tvars propss [] |> sort Term_Ord.tvar_ord |> map_filter instT) @
   281             ((fold o fold) Term.add_tvars propss [] |> sort Term_Ord.tvar_ord |> map_filter instT) @
   282             ((fold o fold) Term.add_vars propss [] |> sort Term_Ord.var_ord |> map_filter inst);
   282             ((fold o fold) Term.add_vars propss [] |> sort Term_Ord.var_ord |> map_filter inst);
   283         in if null prts then [] else [Pretty.big_list title (map inst_pair prts)] end;
   283         in if null prts then [] else [Pretty.big_list title (map inst_pair prts)] end;
   284 
   284 
   285     fun prt_failed prt = [Pretty.block [Pretty.str title, Pretty.brk 1, prt]];
   285     exception LOST_STRUCTURE;
   286 
       
   287     fun goal_matcher () =
   286     fun goal_matcher () =
   288       let
   287       let
   289         val concl = Logic.unprotect (Thm.concl_of goal);
   288         val concl =
       
   289           Logic.unprotect (Thm.concl_of goal)
       
   290             handle TERM _ => raise LOST_STRUCTURE;
   290         val goal_propss = filter_out null propss;
   291         val goal_propss = filter_out null propss;
   291         val results =
   292         val results =
   292           Logic.dest_conjunction_balanced (length goal_propss) concl
   293           Logic.dest_conjunction_balanced (length goal_propss) concl
   293           |> map2 Logic.dest_conjunction_balanced (map length goal_propss);
   294           |> map2 Logic.dest_conjunction_balanced (map length goal_propss)
       
   295             handle TERM _ => raise LOST_STRUCTURE;
   294       in
   296       in
   295         Unify.matcher (Context.Proof ctxt)
   297         Unify.matcher (Context.Proof ctxt)
   296           (map (Soft_Type_System.purge ctxt) (flat goal_propss)) (flat results)
   298           (map (Soft_Type_System.purge ctxt) (flat goal_propss)) (flat results)
   297       end;
   299       end;
       
   300 
       
   301     fun failure msg = (warning (title ^ " " ^ msg); []);
   298   in
   302   in
   299     if Config.get ctxt show_goal_inst then
   303     if Config.get ctxt show_goal_inst then
   300       (case Exn.interruptible_capture goal_matcher () of
   304       (case goal_matcher () of
   301         Exn.Res (SOME env) => prt_inst env
   305         SOME env => prt_inst env
   302       | Exn.Res NONE => prt_failed (Pretty.mark_str (Markup.bad (), "FAILED"))
   306       | NONE => failure "match failed")
   303       | Exn.Exn exn => prt_failed (Runtime.pretty_exn exn))
   307       handle LOST_STRUCTURE => failure "lost goal structure"
   304     else []
   308     else []
   305   end;
   309   end;
   306 
   310 
   307 
   311 
   308 (* method_error *)
   312 (* method_error *)