src/Pure/Isar/experiment.ML
changeset 59901 840d03805755
child 59919 fe1d8576b483
equal deleted inserted replaced
59900:a5591a15112e 59901:840d03805755
       
     1 (*  Title:      Pure/Isar/experiment.ML
       
     2     Author:     Makarius
       
     3 
       
     4 Target for specification experiments that are mostly private.
       
     5 *)
       
     6 
       
     7 signature EXPERIMENT =
       
     8 sig
       
     9   val experiment: Element.context_i list -> theory -> Binding.scope * local_theory
       
    10   val experiment_cmd: Element.context list -> theory -> Binding.scope * local_theory
       
    11 end;
       
    12 
       
    13 structure Experiment: EXPERIMENT =
       
    14 struct
       
    15 
       
    16 fun gen_experiment add_locale elems thy =
       
    17   let
       
    18     val (_, lthy) = thy
       
    19       |> add_locale (Binding.name ("experiment" ^ serial_string ())) Binding.empty ([], []) elems;
       
    20     val (scope, naming) =
       
    21       Name_Space.new_scope (Proof_Context.naming_of (Local_Theory.target_of lthy));
       
    22     val naming' = naming |> Name_Space.private scope;
       
    23     val lthy' = lthy |> Local_Theory.map_contexts (K (Proof_Context.map_naming (K naming')));
       
    24   in (scope, lthy') end;
       
    25 
       
    26 val experiment = gen_experiment Expression.add_locale;
       
    27 val experiment_cmd = gen_experiment Expression.add_locale_cmd;
       
    28 
       
    29 end;