src/Pure/Isar/isar_cmd.ML
changeset 56278 2576d3a40ed6
parent 56275 600f432ab556
child 56304 40274e4f5ebf
equal deleted inserted replaced
56277:c4f75e733812 56278:2576d3a40ed6
    65 (** theory declarations **)
    65 (** theory declarations **)
    66 
    66 
    67 (* generic setup *)
    67 (* generic setup *)
    68 
    68 
    69 fun global_setup source =
    69 fun global_setup source =
    70   ML_Lex.read_source source
    70   ML_Lex.read_source false source
    71   |> ML_Context.expression (#pos source) "val setup: theory -> theory" "Context.map_theory setup"
    71   |> ML_Context.expression (#pos source) "val setup: theory -> theory" "Context.map_theory setup"
    72   |> Context.theory_map;
    72   |> Context.theory_map;
    73 
    73 
    74 fun local_setup source =
    74 fun local_setup source =
    75   ML_Lex.read_source source
    75   ML_Lex.read_source false source
    76   |> ML_Context.expression (#pos source) "val setup: local_theory -> local_theory" "Context.map_proof setup"
    76   |> ML_Context.expression (#pos source) "val setup: local_theory -> local_theory" "Context.map_proof setup"
    77   |> Context.proof_map;
    77   |> Context.proof_map;
    78 
    78 
    79 
    79 
    80 (* translation functions *)
    80 (* translation functions *)
    81 
    81 
    82 fun parse_ast_translation source =
    82 fun parse_ast_translation source =
    83   ML_Lex.read_source source
    83   ML_Lex.read_source false source
    84   |> ML_Context.expression (#pos source)
    84   |> ML_Context.expression (#pos source)
    85     "val parse_ast_translation: (string * (Proof.context -> Ast.ast list -> Ast.ast)) list"
    85     "val parse_ast_translation: (string * (Proof.context -> Ast.ast list -> Ast.ast)) list"
    86     "Context.map_theory (Sign.parse_ast_translation parse_ast_translation)"
    86     "Context.map_theory (Sign.parse_ast_translation parse_ast_translation)"
    87   |> Context.theory_map;
    87   |> Context.theory_map;
    88 
    88 
    89 fun parse_translation source =
    89 fun parse_translation source =
    90   ML_Lex.read_source source
    90   ML_Lex.read_source false source
    91   |> ML_Context.expression (#pos source)
    91   |> ML_Context.expression (#pos source)
    92     "val parse_translation: (string * (Proof.context -> term list -> term)) list"
    92     "val parse_translation: (string * (Proof.context -> term list -> term)) list"
    93     "Context.map_theory (Sign.parse_translation parse_translation)"
    93     "Context.map_theory (Sign.parse_translation parse_translation)"
    94   |> Context.theory_map;
    94   |> Context.theory_map;
    95 
    95 
    96 fun print_translation source =
    96 fun print_translation source =
    97   ML_Lex.read_source source
    97   ML_Lex.read_source false source
    98   |> ML_Context.expression (#pos source)
    98   |> ML_Context.expression (#pos source)
    99     "val print_translation: (string * (Proof.context -> term list -> term)) list"
    99     "val print_translation: (string * (Proof.context -> term list -> term)) list"
   100     "Context.map_theory (Sign.print_translation print_translation)"
   100     "Context.map_theory (Sign.print_translation print_translation)"
   101   |> Context.theory_map;
   101   |> Context.theory_map;
   102 
   102 
   103 fun typed_print_translation source =
   103 fun typed_print_translation source =
   104   ML_Lex.read_source source
   104   ML_Lex.read_source false source
   105   |> ML_Context.expression (#pos source)
   105   |> ML_Context.expression (#pos source)
   106     "val typed_print_translation: (string * (Proof.context -> typ -> term list -> term)) list"
   106     "val typed_print_translation: (string * (Proof.context -> typ -> term list -> term)) list"
   107     "Context.map_theory (Sign.typed_print_translation typed_print_translation)"
   107     "Context.map_theory (Sign.typed_print_translation typed_print_translation)"
   108   |> Context.theory_map;
   108   |> Context.theory_map;
   109 
   109 
   110 fun print_ast_translation source =
   110 fun print_ast_translation source =
   111   ML_Lex.read_source source
   111   ML_Lex.read_source false source
   112   |> ML_Context.expression (#pos source)
   112   |> ML_Context.expression (#pos source)
   113     "val print_ast_translation: (string * (Proof.context -> Ast.ast list -> Ast.ast)) list"
   113     "val print_ast_translation: (string * (Proof.context -> Ast.ast list -> Ast.ast)) list"
   114     "Context.map_theory (Sign.print_ast_translation print_ast_translation)"
   114     "Context.map_theory (Sign.print_ast_translation print_ast_translation)"
   115   |> Context.theory_map;
   115   |> Context.theory_map;
   116 
   116 
   133 
   133 
   134 (* oracles *)
   134 (* oracles *)
   135 
   135 
   136 fun oracle (name, pos) source =
   136 fun oracle (name, pos) source =
   137   let
   137   let
   138     val body = ML_Lex.read_source source;
   138     val body = ML_Lex.read_source false source;
   139     val ants =
   139     val ants =
   140       ML_Lex.read Position.none
   140       ML_Lex.read Position.none
   141        ("local\n\
   141        ("local\n\
   142         \  val binding = " ^ ML_Syntax.make_binding (name, pos) ^ ";\n\
   142         \  val binding = " ^ ML_Syntax.make_binding (name, pos) ^ ";\n\
   143         \  val body = ") @ body @ ML_Lex.read Position.none (";\n\
   143         \  val body = ") @ body @ ML_Lex.read Position.none (";\n\
   160 
   160 
   161 
   161 
   162 (* declarations *)
   162 (* declarations *)
   163 
   163 
   164 fun declaration {syntax, pervasive} source =
   164 fun declaration {syntax, pervasive} source =
   165   ML_Lex.read_source source
   165   ML_Lex.read_source false source
   166   |> ML_Context.expression (#pos source)
   166   |> ML_Context.expression (#pos source)
   167     "val declaration: Morphism.declaration"
   167     "val declaration: Morphism.declaration"
   168     ("Context.map_proof (Local_Theory.declaration {syntax = " ^ Bool.toString syntax ^ ", \
   168     ("Context.map_proof (Local_Theory.declaration {syntax = " ^ Bool.toString syntax ^ ", \
   169       \pervasive = " ^ Bool.toString pervasive ^ "} declaration)")
   169       \pervasive = " ^ Bool.toString pervasive ^ "} declaration)")
   170   |> Context.proof_map;
   170   |> Context.proof_map;
   171 
   171 
   172 
   172 
   173 (* simprocs *)
   173 (* simprocs *)
   174 
   174 
   175 fun simproc_setup name lhss source identifier =
   175 fun simproc_setup name lhss source identifier =
   176   ML_Lex.read_source source
   176   ML_Lex.read_source false source
   177   |> ML_Context.expression (#pos source)
   177   |> ML_Context.expression (#pos source)
   178     "val proc: Morphism.morphism -> Proof.context -> cterm -> thm option"
   178     "val proc: Morphism.morphism -> Proof.context -> cterm -> thm option"
   179     ("Context.map_proof (Simplifier.def_simproc_cmd {name = " ^ ML_Syntax.make_binding name ^ ", \
   179     ("Context.map_proof (Simplifier.def_simproc_cmd {name = " ^ ML_Syntax.make_binding name ^ ", \
   180       \lhss = " ^ ML_Syntax.print_strings lhss ^ ", proc = proc, \
   180       \lhss = " ^ ML_Syntax.print_strings lhss ^ ", proc = proc, \
   181       \identifier = Library.maps ML_Context.thms " ^ ML_Syntax.print_strings identifier ^ "})")
   181       \identifier = Library.maps ML_Context.thms " ^ ML_Syntax.print_strings identifier ^ "})")