src/Pure/Thy/thy_output.ML
changeset 32898 e871d897969c
parent 32890 77df12652210
child 32966 5b21661fe618
equal deleted inserted replaced
32897:2b2c56530d25 32898:e871d897969c
   441 
   441 
   442 val pretty_text = Pretty.chunks o map Pretty.str o map tweak_line o Library.split_lines;
   442 val pretty_text = Pretty.chunks o map Pretty.str o map tweak_line o Library.split_lines;
   443 
   443 
   444 fun pretty_term ctxt t = Syntax.pretty_term (Variable.auto_fixes t ctxt) t;
   444 fun pretty_term ctxt t = Syntax.pretty_term (Variable.auto_fixes t ctxt) t;
   445 
   445 
   446 fun pretty_term_abbrev ctxt t = ProofContext.pretty_term_abbrev (Variable.auto_fixes t ctxt) t;
   446 fun pretty_thm ctxt = pretty_term ctxt o Thm.full_prop_of;
   447 
   447 
   448 fun pretty_term_typ ctxt t =
   448 fun pretty_term_style ctxt (style, t) =
   449   Syntax.pretty_term ctxt (TypeInfer.constrain (Term.fastype_of t) t);
   449   pretty_term ctxt (style t);
   450 
   450 
   451 fun pretty_term_typeof ctxt = Syntax.pretty_typ ctxt o Term.fastype_of;
   451 fun pretty_thm_style ctxt (style, th) =
       
   452   pretty_term ctxt (style (Thm.full_prop_of th));
       
   453 
       
   454 fun pretty_term_typ ctxt (style, t) =
       
   455   let val t' = style t
       
   456   in pretty_term ctxt (TypeInfer.constrain (Term.fastype_of t) t) end;
       
   457 
       
   458 fun pretty_term_typeof ctxt (style, t) =
       
   459   Syntax.pretty_typ ctxt (Term.fastype_of (style t));
   452 
   460 
   453 fun pretty_const ctxt c =
   461 fun pretty_const ctxt c =
   454   let
   462   let
   455     val t = Const (c, Consts.type_scheme (ProofContext.consts_of ctxt) c)
   463     val t = Const (c, Consts.type_scheme (ProofContext.consts_of ctxt) c)
   456       handle TYPE (msg, _, _) => error msg;
   464       handle TYPE (msg, _, _) => error msg;
   464     val (head, args) = Term.strip_comb t;
   472     val (head, args) = Term.strip_comb t;
   465     val (c, T) = Term.dest_Const head handle TERM _ => err ();
   473     val (c, T) = Term.dest_Const head handle TERM _ => err ();
   466     val (U, u) = Consts.the_abbreviation (ProofContext.consts_of ctxt) c
   474     val (U, u) = Consts.the_abbreviation (ProofContext.consts_of ctxt) c
   467       handle TYPE _ => err ();
   475       handle TYPE _ => err ();
   468     val t' = Term.betapplys (Envir.expand_atom T (U, u), args);
   476     val t' = Term.betapplys (Envir.expand_atom T (U, u), args);
   469   in pretty_term_abbrev ctxt (Logic.mk_equals (t, t')) end;
   477     val eq = Logic.mk_equals (t, t');
   470 
   478     val ctxt' = Variable.auto_fixes eq ctxt;
   471 fun pretty_thm ctxt = pretty_term ctxt o Thm.full_prop_of;
   479   in ProofContext.pretty_term_abbrev ctxt' eq end;
   472 
       
   473 fun pretty_term_style ctxt (style, t) =
       
   474   pretty_term ctxt (style t);
       
   475 
       
   476 fun pretty_thm_style ctxt (style, th) =
       
   477   pretty_term_style ctxt (style, Thm.full_prop_of th);
       
   478 
   480 
   479 fun pretty_prf full ctxt = ProofSyntax.pretty_proof_of ctxt full;
   481 fun pretty_prf full ctxt = ProofSyntax.pretty_proof_of ctxt full;
   480 
   482 
   481 fun pretty_theory ctxt name =
   483 fun pretty_theory ctxt name =
   482   (Theory.requires (ProofContext.theory_of ctxt) name "presentation"; Pretty.str name);
   484   (Theory.requires (ProofContext.theory_of ctxt) name "presentation"; Pretty.str name);
   520 fun basic_entity name scan = basic_entities name (scan >> single);
   522 fun basic_entity name scan = basic_entities name (scan >> single);
   521 
   523 
   522 in
   524 in
   523 
   525 
   524 val _ = basic_entities_style "thm" (Term_Style.parse -- Attrib.thms) pretty_thm_style;
   526 val _ = basic_entities_style "thm" (Term_Style.parse -- Attrib.thms) pretty_thm_style;
   525 val _ = basic_entities_style "thm_style" (Term_Style.parse_bare -- Attrib.thms) pretty_thm_style;
       
   526 val _ = basic_entity "prop" (Term_Style.parse -- Args.prop) pretty_term_style;
   527 val _ = basic_entity "prop" (Term_Style.parse -- Args.prop) pretty_term_style;
   527 val _ = basic_entity "term" (Term_Style.parse -- Args.term) pretty_term_style;
   528 val _ = basic_entity "term" (Term_Style.parse -- Args.term) pretty_term_style;
   528 val _ = basic_entity "term_style" (Term_Style.parse_bare -- Args.term) pretty_term_style;
   529 val _ = basic_entity "term_type" (Term_Style.parse -- Args.term) pretty_term_typ;
   529 val _ = basic_entity "term_type" Args.term pretty_term_typ;
   530 val _ = basic_entity "typeof" (Term_Style.parse -- Args.term) pretty_term_typeof;
   530 val _ = basic_entity "typeof" Args.term pretty_term_typeof;
       
   531 val _ = basic_entity "const" Args.const_proper pretty_const;
   531 val _ = basic_entity "const" Args.const_proper pretty_const;
   532 val _ = basic_entity "abbrev" (Scan.lift Args.name_source) pretty_abbrev;
   532 val _ = basic_entity "abbrev" (Scan.lift Args.name_source) pretty_abbrev;
   533 val _ = basic_entity "typ" Args.typ_abbrev Syntax.pretty_typ;
   533 val _ = basic_entity "typ" Args.typ_abbrev Syntax.pretty_typ;
   534 val _ = basic_entity "text" (Scan.lift Args.name) (K pretty_text);
   534 val _ = basic_entity "text" (Scan.lift Args.name) (K pretty_text);
   535 val _ = basic_entities "prf" Attrib.thms (pretty_prf false);
   535 val _ = basic_entities "prf" Attrib.thms (pretty_prf false);
   536 val _ = basic_entities "full_prf" Attrib.thms (pretty_prf true);
   536 val _ = basic_entities "full_prf" Attrib.thms (pretty_prf true);
   537 val _ = basic_entity "theory" (Scan.lift Args.name) pretty_theory;
   537 val _ = basic_entity "theory" (Scan.lift Args.name) pretty_theory;
       
   538 
       
   539 val _ = basic_entities_style "thm_style" (Term_Style.parse_bare -- Attrib.thms) pretty_thm_style;
       
   540 val _ = basic_entity "term_style" (Term_Style.parse_bare -- Args.term) pretty_term_style;
   538 
   541 
   539 end;
   542 end;
   540 
   543 
   541 
   544 
   542 (* goal state *)
   545 (* goal state *)