27 val background_declaration: declaration -> local_theory -> local_theory |
27 val background_declaration: declaration -> local_theory -> local_theory |
28 val locale_declaration: string -> bool -> declaration -> local_theory -> local_theory |
28 val locale_declaration: string -> bool -> declaration -> local_theory -> local_theory |
29 val standard_declaration: (int * int -> bool) -> declaration -> local_theory -> local_theory |
29 val standard_declaration: (int * int -> bool) -> declaration -> local_theory -> local_theory |
30 val generic_const: bool -> Syntax.mode -> (binding * mixfix) * term -> |
30 val generic_const: bool -> Syntax.mode -> (binding * mixfix) * term -> |
31 Context.generic -> Context.generic |
31 Context.generic -> Context.generic |
32 val const_declaration: (int * int -> bool) -> Syntax.mode -> (binding * mixfix) * term -> |
32 val const: (int * int -> bool) -> Syntax.mode -> (binding * mixfix) * term -> |
33 local_theory -> local_theory |
33 local_theory -> local_theory |
34 val locale_const_declaration: string -> Syntax.mode -> (binding * mixfix) * term -> |
34 val locale_const: string -> Syntax.mode -> (binding * mixfix) * term -> |
35 local_theory -> local_theory |
35 local_theory -> local_theory |
36 val background_foundation: ((binding * typ) * mixfix) * (binding * term) -> |
36 val background_foundation: ((binding * typ) * mixfix) * (binding * term) -> |
37 term list * term list -> local_theory -> (term * thm) * local_theory |
37 term list * term list -> local_theory -> (term * thm) * local_theory |
38 val theory_foundation: ((binding * typ) * mixfix) * (binding * term) -> |
38 val theory_foundation: ((binding * typ) * mixfix) * (binding * term) -> |
39 term list * term list -> local_theory -> (term * thm) * local_theory |
39 term list * term list -> local_theory -> (term * thm) * local_theory |
273 |-> (fn (const as Const (c, _), _) => same_shape ? |
273 |-> (fn (const as Const (c, _), _) => same_shape ? |
274 (Proof_Context.generic_revert_abbrev (#1 prmode) c #> |
274 (Proof_Context.generic_revert_abbrev (#1 prmode) c #> |
275 Morphism.form (Proof_Context.generic_notation true prmode [(const, mx)])))) |
275 Morphism.form (Proof_Context.generic_notation true prmode [(const, mx)])))) |
276 end; |
276 end; |
277 |
277 |
278 fun const_declaration pred prmode ((b, mx), rhs) = |
278 fun const pred prmode ((b, mx), rhs) = |
279 standard_declaration pred (fn phi => |
279 standard_declaration pred (fn phi => |
280 let |
280 let |
281 val b' = Morphism.binding phi b; |
281 val b' = Morphism.binding phi b; |
282 val rhs' = Morphism.term phi rhs; |
282 val rhs' = Morphism.term phi rhs; |
283 val same_shape = Term.aconv_untyped (rhs, rhs'); |
283 val same_shape = Term.aconv_untyped (rhs, rhs'); |
284 in generic_const same_shape prmode ((b', mx), rhs') end); |
284 in generic_const same_shape prmode ((b', mx), rhs') end); |
285 |
285 |
286 fun locale_const_declaration locale prmode ((b, mx), rhs) = |
286 fun locale_const locale prmode ((b, mx), rhs) = |
287 locale_declaration locale true (fn phi => |
287 locale_declaration locale true (fn phi => |
288 let |
288 let |
289 val b' = Morphism.binding phi b; |
289 val b' = Morphism.binding phi b; |
290 val rhs' = Morphism.term phi rhs; |
290 val rhs' = Morphism.term phi rhs; |
291 val same_shape = Term.aconv_untyped (rhs, rhs'); |
291 val same_shape = Term.aconv_untyped (rhs, rhs'); |
292 in generic_const same_shape prmode ((b', mx), rhs') end) |
292 in generic_const same_shape prmode ((b', mx), rhs') end) |
293 #> const_declaration |
293 #> const (fn (this, other) => other <> 0 andalso this <> other) prmode ((b, mx), rhs); |
294 (fn (this, other) => other <> 0 andalso this <> other) prmode ((b, mx), rhs); |
|
295 |
294 |
296 |
295 |
297 (* registrations and dependencies *) |
296 (* registrations and dependencies *) |
298 |
297 |
299 val theory_registration = |
298 val theory_registration = |
322 (Thm.def_binding_optional b b_def, Logic.mk_equals (lhs, rhs))); |
321 (Thm.def_binding_optional b b_def, Logic.mk_equals (lhs, rhs))); |
323 in ((lhs, def), lthy3) end; |
322 in ((lhs, def), lthy3) end; |
324 |
323 |
325 fun theory_foundation (((b, U), mx), (b_def, rhs)) (type_params, term_params) = |
324 fun theory_foundation (((b, U), mx), (b_def, rhs)) (type_params, term_params) = |
326 background_foundation (((b, U), mx), (b_def, rhs)) (type_params, term_params) |
325 background_foundation (((b, U), mx), (b_def, rhs)) (type_params, term_params) |
327 #-> (fn (lhs, def) => |
326 #-> (fn (lhs, def) => const (op <>) Syntax.mode_default ((b, mx), lhs) |
328 const_declaration (op <>) Syntax.mode_default ((b, mx), lhs) |
|
329 #> pair (lhs, def)); |
327 #> pair (lhs, def)); |
330 |
328 |
331 fun theory_notes kind global_facts local_facts = |
329 fun theory_notes kind global_facts local_facts = |
332 Local_Theory.background_theory (Attrib.global_notes kind global_facts #> snd) #> |
330 Local_Theory.background_theory (Attrib.global_notes kind global_facts #> snd) #> |
333 (fn lthy => lthy |> Local_Theory.map_contexts (fn level => fn ctxt => |
331 (fn lthy => lthy |> Local_Theory.map_contexts (fn level => fn ctxt => |
339 fun theory_abbrev prmode (b, mx) (t, _) xs = |
337 fun theory_abbrev prmode (b, mx) (t, _) xs = |
340 Local_Theory.background_theory_result |
338 Local_Theory.background_theory_result |
341 (Sign.add_abbrev (#1 prmode) (b, t) #-> |
339 (Sign.add_abbrev (#1 prmode) (b, t) #-> |
342 (fn (lhs, _) => (* FIXME type_params!? *) |
340 (fn (lhs, _) => (* FIXME type_params!? *) |
343 Sign.notation true prmode [(lhs, check_mixfix_global (b, null xs) mx)] #> pair lhs)) |
341 Sign.notation true prmode [(lhs, check_mixfix_global (b, null xs) mx)] #> pair lhs)) |
344 #-> (fn lhs => |
342 #-> (fn lhs => const (op <>) prmode |
345 const_declaration (op <>) prmode |
|
346 ((b, if null xs then NoSyn else mx), Term.list_comb (Logic.unvarify_global lhs, xs))); |
343 ((b, if null xs then NoSyn else mx), Term.list_comb (Logic.unvarify_global lhs, xs))); |
347 |
344 |
348 fun theory_declaration decl = |
345 fun theory_declaration decl = |
349 background_declaration decl #> standard_declaration (K true) decl; |
346 background_declaration decl #> standard_declaration (K true) decl; |
350 |
347 |