src/Pure/Isar/proof_context.ML
changeset 28212 44831b583999
parent 28209 02f3222a392d
child 28396 72695dd4395d
equal deleted inserted replaced
28211:07cfaa1a9e12 28212:44831b583999
    33   val facts_of: Proof.context -> Facts.T
    33   val facts_of: Proof.context -> Facts.T
    34   val transfer_syntax: theory -> Proof.context -> Proof.context
    34   val transfer_syntax: theory -> Proof.context -> Proof.context
    35   val transfer: theory -> Proof.context -> Proof.context
    35   val transfer: theory -> Proof.context -> Proof.context
    36   val theory: (theory -> theory) -> Proof.context -> Proof.context
    36   val theory: (theory -> theory) -> Proof.context -> Proof.context
    37   val theory_result: (theory -> 'a * theory) -> Proof.context -> 'a * Proof.context
    37   val theory_result: (theory -> 'a * theory) -> Proof.context -> 'a * Proof.context
       
    38   val extern_fact: Proof.context -> string -> xstring
    38   val pretty_term_abbrev: Proof.context -> term -> Pretty.T
    39   val pretty_term_abbrev: Proof.context -> term -> Pretty.T
    39   val pretty_thm_legacy: thm -> Pretty.T
    40   val pretty_thm_legacy: thm -> Pretty.T
    40   val pretty_thm: Proof.context -> thm -> Pretty.T
    41   val pretty_thm: Proof.context -> thm -> Pretty.T
    41   val pretty_thms: Proof.context -> thm list -> Pretty.T
    42   val pretty_thms: Proof.context -> thm list -> Pretty.T
    42   val pretty_fact: Proof.context -> string * thm list -> Pretty.T
    43   val pretty_fact: Proof.context -> string * thm list -> Pretty.T
   280 
   281 
   281 
   282 
   282 
   283 
   283 (** pretty printing **)
   284 (** pretty printing **)
   284 
   285 
       
   286 (* extern *)
       
   287 
       
   288 fun extern_fact ctxt name =
       
   289   let
       
   290     val local_facts = facts_of ctxt;
       
   291     val global_facts = PureThy.facts_of (theory_of ctxt);
       
   292   in
       
   293     if is_some (Facts.lookup (Context.Proof ctxt) local_facts name)
       
   294     then Facts.extern local_facts name
       
   295     else Facts.extern global_facts name
       
   296   end;
       
   297 
       
   298 
       
   299 (* pretty *)
       
   300 
   285 fun pretty_term_abbrev ctxt = Syntax.pretty_term (set_mode mode_abbrev ctxt);
   301 fun pretty_term_abbrev ctxt = Syntax.pretty_term (set_mode mode_abbrev ctxt);
   286 
   302 
   287 fun pretty_thm_legacy th =
   303 fun pretty_thm_legacy th =
   288   let val thy = Thm.theory_of_thm th
   304   let val thy = Thm.theory_of_thm th
   289   in Display.pretty_thm_aux (Syntax.pp_global thy) true false [] th end;
   305   in Display.pretty_thm_aux (Syntax.pp_global thy) true false [] th end;
   293   in Display.pretty_thm_aux (Syntax.pp ctxt) false true asms th end;
   309   in Display.pretty_thm_aux (Syntax.pp ctxt) false true asms th end;
   294 
   310 
   295 fun pretty_thms ctxt [th] = pretty_thm ctxt th
   311 fun pretty_thms ctxt [th] = pretty_thm ctxt th
   296   | pretty_thms ctxt ths = Pretty.blk (0, Pretty.fbreaks (map (pretty_thm ctxt) ths));
   312   | pretty_thms ctxt ths = Pretty.blk (0, Pretty.fbreaks (map (pretty_thm ctxt) ths));
   297 
   313 
   298 val extern_fact = Facts.extern o facts_of;
   314 fun pretty_fact_name ctxt a = Pretty.block
       
   315   [Pretty.markup (Markup.fact a) [Pretty.str (extern_fact ctxt a)], Pretty.str ":"];
   299 
   316 
   300 fun pretty_fact ctxt ("", ths) = pretty_thms ctxt ths
   317 fun pretty_fact ctxt ("", ths) = pretty_thms ctxt ths
   301   | pretty_fact ctxt (a, [th]) = Pretty.block
   318   | pretty_fact ctxt (a, [th]) = Pretty.block
   302       [Pretty.str (extern_fact ctxt a ^ ":"), Pretty.brk 1, pretty_thm ctxt th]
   319       [pretty_fact_name ctxt a, Pretty.brk 1, pretty_thm ctxt th]
   303   | pretty_fact ctxt (a, ths) = Pretty.block
   320   | pretty_fact ctxt (a, ths) = Pretty.block
   304       (Pretty.fbreaks (Pretty.str (extern_fact ctxt a ^ ":") :: map (pretty_thm ctxt) ths));
   321       (Pretty.fbreaks (pretty_fact_name ctxt a :: map (pretty_thm ctxt) ths));
   305 
   322 
   306 val string_of_thm = Pretty.string_of oo pretty_thm;
   323 val string_of_thm = Pretty.string_of oo pretty_thm;
   307 
   324 
   308 
   325 
   309 
   326 
  1263   let
  1280   let
  1264     val local_facts = facts_of ctxt;
  1281     val local_facts = facts_of ctxt;
  1265     val props = Facts.props local_facts;
  1282     val props = Facts.props local_facts;
  1266     val facts =
  1283     val facts =
  1267       (if null props then [] else [("unnamed", props)]) @
  1284       (if null props then [] else [("unnamed", props)]) @
  1268       Facts.extern_static [] local_facts;
  1285       Facts.dest_static [] local_facts;
  1269   in
  1286   in
  1270     if null facts andalso not (! verbose) then []
  1287     if null facts andalso not (! verbose) then []
  1271     else [Pretty.big_list "facts:" (map (pretty_fact ctxt) facts)]
  1288     else [Pretty.big_list "facts:" (map #1 (sort_wrt (#1 o #2) (map (`(pretty_fact ctxt)) facts)))]
  1272   end;
  1289   end;
  1273 
  1290 
  1274 val print_lthms = Pretty.writeln o Pretty.chunks o pretty_lthms;
  1291 val print_lthms = Pretty.writeln o Pretty.chunks o pretty_lthms;
  1275 
  1292 
  1276 
  1293