src/Pure/Isar/method.ML
changeset 57937 3bc4725b313e
parent 57935 c578f3a37a67
child 57938 a9fa81e150c9
equal deleted inserted replaced
57936:74ea9ba645c3 57937:3bc4725b313e
   320   fun merge data : T = Name_Space.merge_tables data;
   320   fun merge data : T = Name_Space.merge_tables data;
   321 );
   321 );
   322 
   322 
   323 val get_methods = Methods.get o Context.Proof;
   323 val get_methods = Methods.get o Context.Proof;
   324 
   324 
   325 fun transfer_methods thy ctxt =
   325 fun transfer_methods ctxt =
   326   let
   326   let
   327     val meths' =
   327     val meths0 = Methods.get (Context.Theory (Proof_Context.theory_of ctxt));
   328       Name_Space.merge_tables (Methods.get (Context.Theory thy), get_methods ctxt);
   328     val meths' = Name_Space.merge_tables (meths0, get_methods ctxt);
   329   in Context.proof_map (Methods.put meths') ctxt end;
   329   in Context.proof_map (Methods.put meths') ctxt end;
   330 
   330 
   331 fun print_methods ctxt =
   331 fun print_methods ctxt =
   332   let
   332   let
   333     val meths = get_methods ctxt;
   333     val meths = get_methods ctxt;
   349     val (name, meths') =
   349     val (name, meths') =
   350       Name_Space.define context true (binding, (meth, comment)) (Methods.get context);
   350       Name_Space.define context true (binding, (meth, comment)) (Methods.get context);
   351   in (name, Context.the_theory (Methods.put meths' context)) end;
   351   in (name, Context.the_theory (Methods.put meths' context)) end;
   352 
   352 
   353 fun define binding meth comment lthy =
   353 fun define binding meth comment lthy =
   354   let
   354   let val meth0 = meth o Args.transform_values (Local_Theory.background_morphism lthy) in
   355     val standard_morphism =
       
   356       Local_Theory.standard_morphism lthy (Proof_Context.init_global (Proof_Context.theory_of lthy));
       
   357     val meth0 = meth o Args.transform_values standard_morphism;
       
   358   in
       
   359     lthy
   355     lthy
   360     |> Local_Theory.background_theory_result (define_global binding meth0 comment)
   356     |> Local_Theory.background_theory_result (define_global binding meth0 comment)
   361     |-> (fn name =>
   357     |-> (fn name =>
   362       Local_Theory.map_contexts
   358       Local_Theory.map_contexts (K transfer_methods)
   363         (fn _ => fn ctxt => transfer_methods (Proof_Context.theory_of ctxt) ctxt)
       
   364       #> Local_Theory.declaration {syntax = false, pervasive = false} (fn phi => fn context =>
   359       #> Local_Theory.declaration {syntax = false, pervasive = false} (fn phi => fn context =>
   365           let
   360           let
   366             val naming = Name_Space.naming_of context;
   361             val naming = Name_Space.naming_of context;
   367             val binding' = Morphism.binding phi binding;
   362             val binding' = Morphism.binding phi binding;
   368           in Methods.map (Name_Space.alias_table naming binding' name) context end)
   363           in Methods.map (Name_Space.alias_table naming binding' name) context end)