src/Pure/Isar/proof_context.ML
changeset 21772 7c7ade4f537b
parent 21752 5b7644879373
child 21803 bcef7eb50551
equal deleted inserted replaced
21771:148c8aba89dd 21772:7c7ade4f537b
   291     val t' = t
   291     val t' = t
   292       |> do_abbrevs ? rewrite_term true thy (Consts.abbrevs_of consts (! print_mode @ [""]))
   292       |> do_abbrevs ? rewrite_term true thy (Consts.abbrevs_of consts (! print_mode @ [""]))
   293       |> do_abbrevs ? rewrite_term false thy (Consts.abbrevs_of consts [#1 Syntax.internal_mode])
   293       |> do_abbrevs ? rewrite_term false thy (Consts.abbrevs_of consts [#1 Syntax.internal_mode])
   294       |> Sign.extern_term (Consts.extern_early consts) thy
   294       |> Sign.extern_term (Consts.extern_early consts) thy
   295       |> LocalSyntax.extern_term syntax;
   295       |> LocalSyntax.extern_term syntax;
   296   in
   296   in Sign.pretty_term' ctxt (LocalSyntax.syn_of syntax) (Consts.extern consts) t' end;
   297     Sign.pretty_term' (Context.Proof ctxt) (LocalSyntax.syn_of syntax) (Consts.extern consts) t'
       
   298   end;
       
   299 
   297 
   300 in
   298 in
   301 
   299 
   302 val pretty_term = pretty_term' true;
   300 val pretty_term = pretty_term' true;
   303 val pretty_term_abbrev = pretty_term' false;
   301 val pretty_term_abbrev = pretty_term' false;
   353 (** prepare types **)
   351 (** prepare types **)
   354 
   352 
   355 local
   353 local
   356 
   354 
   357 fun read_typ_aux read ctxt s =
   355 fun read_typ_aux read ctxt s =
   358   read (syn_of ctxt) (Context.Proof ctxt) (Variable.def_sort ctxt) s;
   356   read (syn_of ctxt) ctxt (Variable.def_sort ctxt) s;
   359 
   357 
   360 fun cert_typ_aux cert ctxt raw_T =
   358 fun cert_typ_aux cert ctxt raw_T =
   361   cert (theory_of ctxt) raw_T handle TYPE (msg, _, _) => error msg;
   359   cert (theory_of ctxt) raw_T handle TYPE (msg, _, _) => error msg;
   362 
   360 
   363 in
   361 in
   433 
   431 
   434 (* read wrt. theory *)     (*exception ERROR*)
   432 (* read wrt. theory *)     (*exception ERROR*)
   435 
   433 
   436 fun read_def_termTs freeze pp syn ctxt (types, sorts, used) sTs =
   434 fun read_def_termTs freeze pp syn ctxt (types, sorts, used) sTs =
   437   Sign.read_def_terms' pp (Sign.is_logtype (theory_of ctxt)) syn (consts_of ctxt)
   435   Sign.read_def_terms' pp (Sign.is_logtype (theory_of ctxt)) syn (consts_of ctxt)
   438     (Context.Proof ctxt) (types, sorts) used freeze sTs;
   436     ctxt (types, sorts) used freeze sTs;
   439 
   437 
   440 fun read_def_termT freeze pp syn ctxt defaults sT =
   438 fun read_def_termT freeze pp syn ctxt defaults sT =
   441   apfst hd (read_def_termTs freeze pp syn ctxt defaults [sT]);
   439   apfst hd (read_def_termTs freeze pp syn ctxt defaults [sT]);
   442 
   440 
   443 fun read_term_thy freeze pp syn thy defaults s =
   441 fun read_term_thy freeze pp syn thy defaults s =
   863 fun const_syntax ctxt (Free (x, T), mx) = SOME (true, (x, T, mx))
   861 fun const_syntax ctxt (Free (x, T), mx) = SOME (true, (x, T, mx))
   864   | const_syntax ctxt (Const (c, _), mx) =
   862   | const_syntax ctxt (Const (c, _), mx) =
   865       Option.map (pair false) (try (Consts.syntax (consts_of ctxt)) (c, mx))
   863       Option.map (pair false) (try (Consts.syntax (consts_of ctxt)) (c, mx))
   866   | const_syntax _ _ = NONE;
   864   | const_syntax _ _ = NONE;
   867 
   865 
   868 fun context_const_ast_tr context [Syntax.Variable c] =
   866 fun context_const_ast_tr ctxt [Syntax.Variable c] =
   869       let
   867       let
   870         val consts = Context.cases Sign.consts_of consts_of context;
   868         val consts = consts_of ctxt;
   871         val c' = Consts.intern consts c;
   869         val c' = Consts.intern consts c;
   872         val _ = Consts.the_constraint consts c' handle TYPE (msg, _, _) => error msg;
   870         val _ = Consts.the_constraint consts c' handle TYPE (msg, _, _) => error msg;
   873       in Syntax.Constant (Syntax.constN ^ c') end
   871       in Syntax.Constant (Syntax.constN ^ c') end
   874   | context_const_ast_tr _ asts = raise Syntax.AST ("const_ast_tr", asts);
   872   | context_const_ast_tr _ asts = raise Syntax.AST ("const_ast_tr", asts);
   875 
   873