src/Pure/Isar/isar_output.ML
changeset 21717 410ca6910f6f
parent 21360 c63755004033
child 21762 c7ca3b57557f
equal deleted inserted replaced
21716:8fcacb0e3b15 21717:410ca6910f6f
   439   if ! display then s else Symbol.strip_blanks s;
   439   if ! display then s else Symbol.strip_blanks s;
   440 
   440 
   441 val pretty_text = Pretty.chunks o map Pretty.str o map tweak_line o Library.split_lines;
   441 val pretty_text = Pretty.chunks o map Pretty.str o map tweak_line o Library.split_lines;
   442 
   442 
   443 fun pretty_term ctxt = ProofContext.pretty_term ctxt o ProofContext.revert_skolems ctxt;
   443 fun pretty_term ctxt = ProofContext.pretty_term ctxt o ProofContext.revert_skolems ctxt;
       
   444 fun pretty_term_abbrev ctxt =
       
   445   ProofContext.pretty_term_abbrev ctxt o ProofContext.revert_skolems ctxt;
   444 
   446 
   445 fun pretty_term_typ ctxt t =
   447 fun pretty_term_typ ctxt t =
   446   ProofContext.pretty_term ctxt (TypeInfer.constrain t (Term.fastype_of t));
   448   ProofContext.pretty_term ctxt (TypeInfer.constrain t (Term.fastype_of t));
   447 
   449 
   448 fun pretty_term_typeof ctxt = ProofContext.pretty_typ ctxt o Term.fastype_of;
   450 fun pretty_term_typeof ctxt = ProofContext.pretty_typ ctxt o Term.fastype_of;
   449 
   451 
   450 fun pretty_term_const ctxt t =
   452 fun pretty_term_const ctxt t =
   451   if Term.is_Const t then pretty_term ctxt t
   453   if Term.is_Const t then pretty_term ctxt t
   452   else error ("Logical constant expected: " ^ ProofContext.string_of_term ctxt t);
   454   else error ("Logical constant expected: " ^ ProofContext.string_of_term ctxt t);
       
   455 
       
   456 fun pretty_abbrev ctxt t =
       
   457   let
       
   458     fun err () = error ("Abbreviated constant expected: " ^ ProofContext.string_of_term ctxt t);
       
   459     val (head, args) = Term.strip_comb t;
       
   460     val (c, T) = Term.dest_Const head handle TERM _ => err ();
       
   461     val (U, (u, _)) = Consts.the_abbreviation (ProofContext.consts_of ctxt) c
       
   462       handle TYPE _ => err ();
       
   463     val t' = Term.betapplys (Envir.expand_atom T (U, u), args);
       
   464   in pretty_term_abbrev ctxt (Logic.mk_equals (t, t')) end;
   453 
   465 
   454 fun pretty_thm ctxt = pretty_term ctxt o Thm.full_prop_of;
   466 fun pretty_thm ctxt = pretty_term ctxt o Thm.full_prop_of;
   455 
   467 
   456 fun pretty_term_style ctxt (name, t) =
   468 fun pretty_term_style ctxt (name, t) =
   457   pretty_term ctxt (TermStyle.the_style (ProofContext.theory_of ctxt) name ctxt t);
   469   pretty_term ctxt (TermStyle.the_style (ProofContext.theory_of ctxt) name ctxt t);
   515   ("term", args Args.term (output pretty_term)),
   527   ("term", args Args.term (output pretty_term)),
   516   ("term_style", args (Scan.lift Args.liberal_name -- Args.term) (output pretty_term_style)),
   528   ("term_style", args (Scan.lift Args.liberal_name -- Args.term) (output pretty_term_style)),
   517   ("term_type", args Args.term (output pretty_term_typ)),
   529   ("term_type", args Args.term (output pretty_term_typ)),
   518   ("typeof", args Args.term (output pretty_term_typeof)),
   530   ("typeof", args Args.term (output pretty_term_typeof)),
   519   ("const", args Args.term (output pretty_term_const)),
   531   ("const", args Args.term (output pretty_term_const)),
       
   532   ("abbrev", args Args.term_abbrev (output pretty_abbrev)),
   520   ("typ", args Args.typ_abbrev (output ProofContext.pretty_typ)),
   533   ("typ", args Args.typ_abbrev (output ProofContext.pretty_typ)),
   521   ("text", args (Scan.lift Args.name) (output (K pretty_text))),
   534   ("text", args (Scan.lift Args.name) (output (K pretty_text))),
   522   ("goals", output_goals true),
   535   ("goals", output_goals true),
   523   ("subgoals", output_goals false),
   536   ("subgoals", output_goals false),
   524   ("prf", args Attrib.thms (output (pretty_prf false))),
   537   ("prf", args Attrib.thms (output (pretty_prf false))),