53 val notes: Attrib.fact list -> local_theory -> (string * thm list) list * local_theory |
53 val notes: Attrib.fact list -> local_theory -> (string * thm list) list * local_theory |
54 val notes_kind: string -> Attrib.fact list -> local_theory -> |
54 val notes_kind: string -> Attrib.fact list -> local_theory -> |
55 (string * thm list) list * local_theory |
55 (string * thm list) list * local_theory |
56 val abbrev: Syntax.mode -> (binding * mixfix) * term -> local_theory -> |
56 val abbrev: Syntax.mode -> (binding * mixfix) * term -> local_theory -> |
57 (term * term) * local_theory |
57 (term * term) * local_theory |
58 val declaration: {syntax: bool, pervasive: bool} -> Morphism.declaration -> |
58 val declaration: {syntax: bool, pervasive: bool, pos: Position.T} -> Morphism.declaration -> |
59 local_theory -> local_theory |
59 local_theory -> local_theory |
60 val theory_registration: Locale.registration -> local_theory -> local_theory |
60 val theory_registration: Locale.registration -> local_theory -> local_theory |
61 val locale_dependency: Locale.registration -> local_theory -> local_theory |
61 val locale_dependency: Locale.registration -> local_theory -> local_theory |
62 val pretty: local_theory -> Pretty.T list |
62 val pretty: local_theory -> Pretty.T list |
63 val add_thms_dynamic: binding * (Context.generic -> thm list) -> local_theory -> local_theory |
63 val add_thms_dynamic: binding * (Context.generic -> thm list) -> local_theory -> local_theory |
101 {define: bool -> (binding * mixfix) * (Attrib.binding * term) -> local_theory -> |
101 {define: bool -> (binding * mixfix) * (Attrib.binding * term) -> local_theory -> |
102 (term * (string * thm)) * local_theory, |
102 (term * (string * thm)) * local_theory, |
103 notes: string -> Attrib.fact list -> local_theory -> (string * thm list) list * local_theory, |
103 notes: string -> Attrib.fact list -> local_theory -> (string * thm list) list * local_theory, |
104 abbrev: Syntax.mode -> (binding * mixfix) * term -> local_theory -> |
104 abbrev: Syntax.mode -> (binding * mixfix) * term -> local_theory -> |
105 (term * term) * local_theory, |
105 (term * term) * local_theory, |
106 declaration: {syntax: bool, pervasive: bool} -> Morphism.declaration_entity -> |
106 declaration: {syntax: bool, pervasive: bool, pos: Position.T} -> Morphism.declaration_entity -> |
107 local_theory -> local_theory, |
107 local_theory -> local_theory, |
108 theory_registration: Locale.registration -> local_theory -> local_theory, |
108 theory_registration: Locale.registration -> local_theory -> local_theory, |
109 locale_dependency: Locale.registration -> local_theory -> local_theory, |
109 locale_dependency: Locale.registration -> local_theory -> local_theory, |
110 pretty: local_theory -> Pretty.T list}; |
110 pretty: local_theory -> Pretty.T list}; |
111 |
111 |
299 |> background_theory_result (fn thy => thy |
299 |> background_theory_result (fn thy => thy |
300 |> Global_Theory.add_thms_dynamic' (Sign.inherit_naming thy lthy) (binding, f)) |
300 |> Global_Theory.add_thms_dynamic' (Sign.inherit_naming thy lthy) (binding, f)) |
301 |-> (fn name => |
301 |-> (fn name => |
302 map_contexts (fn _ => fn ctxt => |
302 map_contexts (fn _ => fn ctxt => |
303 Proof_Context.transfer_facts (Proof_Context.theory_of ctxt) ctxt) #> |
303 Proof_Context.transfer_facts (Proof_Context.theory_of ctxt) ctxt) #> |
304 declaration {syntax = false, pervasive = false} (fn phi => |
304 declaration {syntax = false, pervasive = false, pos = Binding.pos_of binding} (fn phi => |
305 let val binding' = Morphism.binding phi binding in |
305 let val binding' = Morphism.binding phi binding in |
306 Context.mapping |
306 Context.mapping |
307 (Global_Theory.alias_fact binding' name) |
307 (Global_Theory.alias_fact binding' name) |
308 (Proof_Context.alias_fact binding' name) |
308 (Proof_Context.alias_fact binding' name) |
309 end)); |
309 end)); |
310 |
310 |
311 |
311 |
312 (* default sort *) |
312 (* default sort *) |
313 |
313 |
314 fun set_defsort S = |
314 fun set_defsort S = |
315 declaration {syntax = true, pervasive = false} |
315 declaration {syntax = true, pervasive = false, pos = Position.thread_data ()} |
316 (K (Context.mapping (Sign.set_defsort S) (Proof_Context.set_defsort S))); |
316 (K (Context.mapping (Sign.set_defsort S) (Proof_Context.set_defsort S))); |
317 |
317 |
318 |
318 |
319 (* syntax *) |
319 (* syntax *) |
320 |
320 |
322 let |
322 let |
323 val args = map (fn (c, T, mx) => (c, prep_type lthy T, mx)) raw_args; |
323 val args = map (fn (c, T, mx) => (c, prep_type lthy T, mx)) raw_args; |
324 val args' = map (fn (c, T, mx) => (c, T, Mixfix.reset_pos mx)) args; |
324 val args' = map (fn (c, T, mx) => (c, T, Mixfix.reset_pos mx)) args; |
325 val _ = lthy |> Context_Position.is_visible lthy ? Proof_Context.syntax add mode args; |
325 val _ = lthy |> Context_Position.is_visible lthy ? Proof_Context.syntax add mode args; |
326 in |
326 in |
327 declaration {syntax = true, pervasive = false} |
327 declaration {syntax = true, pervasive = false, pos = Position.thread_data ()} |
328 (fn _ => Proof_Context.generic_syntax add mode args') lthy |
328 (fn _ => Proof_Context.generic_syntax add mode args') lthy |
329 end; |
329 end; |
330 |
330 |
331 val syntax = gen_syntax (K I); |
331 val syntax = gen_syntax (K I); |
332 val syntax_cmd = gen_syntax Proof_Context.read_typ_syntax; |
332 val syntax_cmd = gen_syntax Proof_Context.read_typ_syntax; |
341 val prepare = prep_type lthy #> Logic.type_map (Assumption.export_term lthy (target_of lthy)); |
341 val prepare = prep_type lthy #> Logic.type_map (Assumption.export_term lthy (target_of lthy)); |
342 val args = map (apfst prepare) raw_args; |
342 val args = map (apfst prepare) raw_args; |
343 val args' = map (apsnd Mixfix.reset_pos) args; |
343 val args' = map (apsnd Mixfix.reset_pos) args; |
344 val _ = lthy |> Context_Position.is_visible lthy ? Proof_Context.type_notation add mode args; |
344 val _ = lthy |> Context_Position.is_visible lthy ? Proof_Context.type_notation add mode args; |
345 in |
345 in |
346 declaration {syntax = true, pervasive = false} |
346 declaration {syntax = true, pervasive = false, pos = Position.thread_data ()} |
347 (Proof_Context.generic_type_notation add mode args') lthy |
347 (Proof_Context.generic_type_notation add mode args') lthy |
348 end; |
348 end; |
349 |
349 |
350 fun gen_notation prep_const add mode raw_args lthy = |
350 fun gen_notation prep_const add mode raw_args lthy = |
351 let |
351 let |
352 val prepare = prep_const lthy #> Assumption.export_term lthy (target_of lthy); |
352 val prepare = prep_const lthy #> Assumption.export_term lthy (target_of lthy); |
353 val args = map (apfst prepare) raw_args; |
353 val args = map (apfst prepare) raw_args; |
354 val args' = map (apsnd Mixfix.reset_pos) args; |
354 val args' = map (apsnd Mixfix.reset_pos) args; |
355 val _ = lthy |> Context_Position.is_visible lthy ? Proof_Context.notation add mode args; |
355 val _ = lthy |> Context_Position.is_visible lthy ? Proof_Context.notation add mode args; |
356 in |
356 in |
357 declaration {syntax = true, pervasive = false} |
357 declaration {syntax = true, pervasive = false, pos = Position.thread_data ()} |
358 (Proof_Context.generic_notation add mode args') lthy |
358 (Proof_Context.generic_notation add mode args') lthy |
359 end; |
359 end; |
360 |
360 |
361 in |
361 in |
362 |
362 |
371 |
371 |
372 |
372 |
373 (* name space aliases *) |
373 (* name space aliases *) |
374 |
374 |
375 fun syntax_alias global_alias local_alias b name = |
375 fun syntax_alias global_alias local_alias b name = |
376 declaration {syntax = true, pervasive = false} (fn phi => |
376 declaration {syntax = true, pervasive = false, pos = Position.thread_data ()} (fn phi => |
377 let val b' = Morphism.binding phi b |
377 let val b' = Morphism.binding phi b |
378 in Context.mapping (global_alias b' name) (local_alias b' name) end); |
378 in Context.mapping (global_alias b' name) (local_alias b' name) end); |
379 |
379 |
380 val type_alias = syntax_alias Sign.type_alias Proof_Context.type_alias; |
380 val type_alias = syntax_alias Sign.type_alias Proof_Context.type_alias; |
381 val const_alias = syntax_alias Sign.const_alias Proof_Context.const_alias; |
381 val const_alias = syntax_alias Sign.const_alias Proof_Context.const_alias; |