src/Pure/Isar/isar_output.ML
changeset 12055 a9c44895cc8c
parent 11861 38d8075ebff6
child 12805 3be853cf19cf
equal deleted inserted replaced
12054:a96c9563d568 12055:a9c44895cc8c
   290 val pretty_text = Pretty.chunks o map Pretty.str o map tweak_line o Library.split_lines;
   290 val pretty_text = Pretty.chunks o map Pretty.str o map tweak_line o Library.split_lines;
   291 
   291 
   292 val pretty_source =
   292 val pretty_source =
   293   pretty_text o space_implode " " o map Args.string_of o #2 o #1 o Args.dest_src;
   293   pretty_text o space_implode " " o map Args.string_of o #2 o #1 o Args.dest_src;
   294 
   294 
   295 fun pretty_typ ctxt T =
   295 fun pretty_term ctxt = ProofContext.pretty_term ctxt o ProofContext.extern_skolem ctxt;
   296   Sign.pretty_typ (ProofContext.sign_of ctxt) T;
   296 
   297 
   297 fun pretty_thms ctxt thms =
   298 fun pretty_term ctxt t =
       
   299   Sign.pretty_term (ProofContext.sign_of ctxt) (ProofContext.extern_skolem ctxt t);
       
   300 
       
   301 fun pretty_thm ctxt thms =
       
   302   Pretty.chunks (map (pretty_term ctxt o #prop o Thm.rep_thm) thms);
   298   Pretty.chunks (map (pretty_term ctxt o #prop o Thm.rep_thm) thms);
   303 
   299 
   304 fun pretty_prf full ctxt thms =
   300 fun pretty_prf full ctxt thms =    (* FIXME context syntax!? *)
   305   Pretty.chunks (map (ProofSyntax.pretty_proof_of full) thms);
   301   Pretty.chunks (map (ProofSyntax.pretty_proof_of full) thms);
   306 
   302 
   307 fun output_with pretty src ctxt x =
   303 fun output_with pretty src ctxt x =
   308   let
   304   let
   309     val prt = pretty ctxt x;      (*always pretty!*)
   305     val prt = pretty ctxt x;      (*always pretty in order to catch errors!*)
   310     val prt' = if ! source then pretty_source src else prt;
   306     val prt' = if ! source then pretty_source src else prt;
   311   in cond_display (cond_quote prt') end;
   307   in cond_display (cond_quote prt') end;
   312 
   308 
   313 fun output_goals main_goal src state = args (Scan.succeed ()) (output_with (fn _ => fn _ =>
   309 fun output_goals main_goal src state = args (Scan.succeed ()) (output_with (fn _ => fn _ =>
   314   Pretty.chunks (Proof.pretty_goals main_goal (Toplevel.proof_of state
   310   Pretty.chunks (Proof.pretty_goals main_goal (Toplevel.proof_of state
   315       handle Toplevel.UNDEF => error "No proof state")))) src state;
   311       handle Toplevel.UNDEF => error "No proof state")))) src state;
   316 
   312 
   317 val _ = add_commands
   313 val _ = add_commands
   318  [("text", args (Scan.lift Args.name) (output_with (K pretty_text))),
   314  [("text", args (Scan.lift Args.name) (output_with (K pretty_text))),
   319   ("thm", args Attrib.local_thmss (output_with pretty_thm)),
   315   ("thm", args Attrib.local_thmss (output_with pretty_thms)),
   320   ("prf", args Attrib.local_thmss (output_with (pretty_prf false))),
   316   ("prf", args Attrib.local_thmss (output_with (pretty_prf false))),
   321   ("full_prf", args Attrib.local_thmss (output_with (pretty_prf true))),
   317   ("full_prf", args Attrib.local_thmss (output_with (pretty_prf true))),
   322   ("prop", args Args.local_prop (output_with pretty_term)),
   318   ("prop", args Args.local_prop (output_with pretty_term)),
   323   ("term", args Args.local_term (output_with pretty_term)),
   319   ("term", args Args.local_term (output_with pretty_term)),
   324   ("typ", args Args.local_typ_no_norm (output_with pretty_typ)),
   320   ("typ", args Args.local_typ_no_norm (output_with ProofContext.pretty_typ)),
   325   ("goals", output_goals true),
   321   ("goals", output_goals true),
   326   ("subgoals", output_goals false)];
   322   ("subgoals", output_goals false)];
   327 
   323 
   328 end;
   324 end;