| author | wenzelm | 
| Mon, 29 Jul 2019 10:26:12 +0200 | |
| changeset 70435 | 52fbcf7a61f8 | 
| parent 70314 | 6d6839a948cf | 
| child 72451 | e51f1733618d | 
| permissions | -rw-r--r-- | 
| 61669 | 1 | (* Title: Pure/Isar/interpretation.ML | 
| 2 | Author: Clemens Ballarin, TU Muenchen | |
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 3 | Author: Florian Haftmann, TU Muenchen | 
| 61669 | 4 | |
| 5 | Locale interpretation. | |
| 6 | *) | |
| 7 | ||
| 8 | signature INTERPRETATION = | |
| 9 | sig | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 10 | type 'a defines = (Attrib.binding * ((binding * mixfix) * 'a)) list | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 11 | |
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 12 | (*interpretation in proofs*) | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 13 | val interpret: Expression.expression_i -> Proof.state -> Proof.state | 
| 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 14 | val interpret_cmd: Expression.expression -> Proof.state -> Proof.state | 
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 15 | |
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 16 | (*interpretation in local theories*) | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 17 | val interpretation: Expression.expression_i -> local_theory -> Proof.state | 
| 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 18 | val interpretation_cmd: Expression.expression -> local_theory -> Proof.state | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 19 | |
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 20 | (*interpretation into global theories*) | 
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 21 | val global_interpretation: Expression.expression_i -> | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 22 | term defines -> local_theory -> Proof.state | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 23 | val global_interpretation_cmd: Expression.expression -> | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 24 | string defines -> local_theory -> Proof.state | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 25 | |
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 26 | (*interpretation between locales*) | 
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 27 | val sublocale: Expression.expression_i -> | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 28 | term defines -> local_theory -> Proof.state | 
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 29 | val sublocale_cmd: Expression.expression -> | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 30 | string defines -> local_theory -> Proof.state | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 31 | val global_sublocale: string -> Expression.expression_i -> | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 32 | term defines -> theory -> Proof.state | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 33 | val global_sublocale_cmd: xstring * Position.T -> Expression.expression -> | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 34 | string defines -> theory -> Proof.state | 
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 35 | |
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 36 | (*mixed Isar interface*) | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 37 | val isar_interpretation: Expression.expression_i -> local_theory -> Proof.state | 
| 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 38 | val isar_interpretation_cmd: Expression.expression -> local_theory -> Proof.state | 
| 61669 | 39 | end; | 
| 40 | ||
| 41 | structure Interpretation : INTERPRETATION = | |
| 42 | struct | |
| 43 | ||
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 44 | (** common interpretation machinery **) | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 45 | |
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 46 | type 'a defines = (Attrib.binding * ((binding * mixfix) * 'a)) list | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 47 | |
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 48 | (* reading of locale expressions with rewrite morphisms *) | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 49 | |
| 61672 
87203a0f0041
tuned -- share implementations as far as appropriate
 haftmann parents: 
61670diff
changeset | 50 | local | 
| 61669 | 51 | |
| 67450 
b0ae74b86ef3
Experimental support for rewrite morphisms in locale instances.
 ballarin parents: 
66334diff
changeset | 52 | fun augment_with_def prep_term ((name, atts), ((b, mx), raw_rhs)) lthy = | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 53 | let | 
| 61775 
ec11275fb263
alternating parsing and defining of rewrite definitions: formally correct treatment of polymorphism
 haftmann parents: 
61774diff
changeset | 54 | val rhs = prep_term lthy raw_rhs; | 
| 
ec11275fb263
alternating parsing and defining of rewrite definitions: formally correct treatment of polymorphism
 haftmann parents: 
61774diff
changeset | 55 | val lthy' = Variable.declare_term rhs lthy; | 
| 
ec11275fb263
alternating parsing and defining of rewrite definitions: formally correct treatment of polymorphism
 haftmann parents: 
61774diff
changeset | 56 | val ((_, (_, def)), lthy'') = | 
| 
ec11275fb263
alternating parsing and defining of rewrite definitions: formally correct treatment of polymorphism
 haftmann parents: 
61774diff
changeset | 57 | Local_Theory.define ((b, mx), ((Thm.def_binding_optional b name, atts), rhs)) lthy'; | 
| 69699 
82f57315cade
dedicated combinator for declarations nested in a local theory block
 haftmann parents: 
69058diff
changeset | 58 | in (Thm.symmetric def, lthy'') end; | 
| 61669 | 59 | |
| 69699 
82f57315cade
dedicated combinator for declarations nested in a local theory block
 haftmann parents: 
69058diff
changeset | 60 | fun augment_with_defs _ [] _ = pair [] | 
| 61691 
91854ba66adb
clarified contexts by factoring out reading and definition of mixins
 haftmann parents: 
61684diff
changeset | 61 | (*quasi-inhomogeneous type: definitions demand local theory rather than bare proof context*) | 
| 69699 
82f57315cade
dedicated combinator for declarations nested in a local theory block
 haftmann parents: 
69058diff
changeset | 62 | | augment_with_defs prep_term raw_defs deps = | 
| 
82f57315cade
dedicated combinator for declarations nested in a local theory block
 haftmann parents: 
69058diff
changeset | 63 | Local_Theory.subtarget_result Morphism.fact | 
| 
82f57315cade
dedicated combinator for declarations nested in a local theory block
 haftmann parents: 
69058diff
changeset | 64 | (fold Locale.activate_declarations deps | 
| 
82f57315cade
dedicated combinator for declarations nested in a local theory block
 haftmann parents: 
69058diff
changeset | 65 | #> fold_map (augment_with_def prep_term) raw_defs); | 
| 61775 
ec11275fb263
alternating parsing and defining of rewrite definitions: formally correct treatment of polymorphism
 haftmann parents: 
61774diff
changeset | 66 | |
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 67 | fun prep_interpretation prep_expr prep_term | 
| 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 68 | expression raw_defs initial_ctxt = | 
| 61691 
91854ba66adb
clarified contexts by factoring out reading and definition of mixins
 haftmann parents: 
61684diff
changeset | 69 | let | 
| 67450 
b0ae74b86ef3
Experimental support for rewrite morphisms in locale instances.
 ballarin parents: 
66334diff
changeset | 70 | val ((propss, eq_propss, deps, eqnss, export), expr_ctxt) = prep_expr expression initial_ctxt; | 
| 61775 
ec11275fb263
alternating parsing and defining of rewrite definitions: formally correct treatment of polymorphism
 haftmann parents: 
61774diff
changeset | 71 | val (def_eqns, def_ctxt) = | 
| 
ec11275fb263
alternating parsing and defining of rewrite definitions: formally correct treatment of polymorphism
 haftmann parents: 
61774diff
changeset | 72 | augment_with_defs prep_term raw_defs deps expr_ctxt; | 
| 70314 
6d6839a948cf
proper Proof_Context.export_morphism corresponding to Proof_Context.augment (see 7f568724d67e);
 wenzelm parents: 
69699diff
changeset | 73 | val export' = Proof_Context.export_morphism def_ctxt expr_ctxt; | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 74 | in (((propss, eq_propss, deps, eqnss, export, export'), def_eqns), def_ctxt) end; | 
| 61669 | 75 | |
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 76 | in | 
| 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 77 | |
| 61698 | 78 | fun cert_interpretation expression = | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 79 | prep_interpretation Expression.cert_goal_expression Syntax.check_term expression; | 
| 61672 
87203a0f0041
tuned -- share implementations as far as appropriate
 haftmann parents: 
61670diff
changeset | 80 | |
| 61698 | 81 | fun read_interpretation expression = | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 82 | prep_interpretation Expression.read_goal_expression Syntax.read_term expression; | 
| 61669 | 83 | |
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 84 | end; | 
| 61669 | 85 | |
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 86 | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 87 | (* interpretation machinery *) | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 88 | |
| 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 89 | local | 
| 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 90 | |
| 68854 | 91 | fun abs_def_rule eqns ctxt = | 
| 63381 | 92 | (map (Local_Defs.abs_def_rule ctxt) (maps snd eqns), ctxt); | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 93 | |
| 68855 
59ce31e15c33
more careful treatment position: existing facts refer to interpretation command, future facts refer to themselves (see also 4270da306442);
 wenzelm parents: 
68854diff
changeset | 94 | fun note_eqns_register note add_registration | 
| 68849 | 95 | deps eqnss witss def_eqns thms export export' ctxt = | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 96 | let | 
| 68849 | 97 | val factss = thms | 
| 98 | |> unflat ((map o map) #1 eqnss) | |
| 99 | |> map2 (map2 (fn b => fn eq => (b, [([Morphism.thm export eq], [])]))) ((map o map) #1 eqnss); | |
| 100 | val (eqnss', ctxt') = | |
| 68854 | 101 | fold_map (fn facts => note Thm.theoremK facts #-> abs_def_rule) factss ctxt; | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 102 | val defs = (Binding.empty_atts, [(map (Morphism.thm (export' $> export)) def_eqns, [])]); | 
| 68854 | 103 | val (eqns', ctxt'') = ctxt' |> note Thm.theoremK [defs] |-> abs_def_rule; | 
| 104 | val deps' = | |
| 105 | (deps ~~ witss) |> map (fn ((dep, morph), wits) => | |
| 68855 
59ce31e15c33
more careful treatment position: existing facts refer to interpretation command, future facts refer to themselves (see also 4270da306442);
 wenzelm parents: 
68854diff
changeset | 106 | (dep, morph $> Element.satisfy_morphism (map (Element.transform_witness export') wits))); | 
| 68854 | 107 | fun register (dep, eqns) ctxt = | 
| 68851 
6c9825c1e26b
clarified signature: explicit type Locale.registration;
 wenzelm parents: 
68850diff
changeset | 108 | ctxt |> add_registration | 
| 69058 | 109 |         {inst = dep,
 | 
| 68851 
6c9825c1e26b
clarified signature: explicit type Locale.registration;
 wenzelm parents: 
68850diff
changeset | 110 | mixin = | 
| 
6c9825c1e26b
clarified signature: explicit type Locale.registration;
 wenzelm parents: 
68850diff
changeset | 111 | Option.map (rpair true) | 
| 
6c9825c1e26b
clarified signature: explicit type Locale.registration;
 wenzelm parents: 
68850diff
changeset | 112 | (Element.eq_morphism (Proof_Context.theory_of ctxt) (eqns @ eqns')), | 
| 
6c9825c1e26b
clarified signature: explicit type Locale.registration;
 wenzelm parents: 
68850diff
changeset | 113 | export = export}; | 
| 68854 | 114 | in ctxt'' |> fold register (deps' ~~ eqnss') end; | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 115 | |
| 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 116 | in | 
| 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 117 | |
| 63380 | 118 | fun generic_interpretation prep_interpretation setup_proof note add_registration | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 119 | expression raw_defs initial_ctxt = | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 120 | let | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 121 | val (((propss, eq_propss, deps, eqnss, export, export'), def_eqns), goal_ctxt) = | 
| 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 122 | prep_interpretation expression raw_defs initial_ctxt; | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 123 | fun after_qed witss eqns = | 
| 68855 
59ce31e15c33
more careful treatment position: existing facts refer to interpretation command, future facts refer to themselves (see also 4270da306442);
 wenzelm parents: 
68854diff
changeset | 124 | note_eqns_register note add_registration deps eqnss witss def_eqns eqns export export'; | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 125 | in setup_proof after_qed propss (flat eq_propss) goal_ctxt end; | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 126 | |
| 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 127 | end; | 
| 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 128 | |
| 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 129 | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 130 | (** interfaces **) | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 131 | |
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 132 | (* interpretation in proofs *) | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 133 | |
| 61672 
87203a0f0041
tuned -- share implementations as far as appropriate
 haftmann parents: 
61670diff
changeset | 134 | local | 
| 
87203a0f0041
tuned -- share implementations as far as appropriate
 haftmann parents: 
61670diff
changeset | 135 | |
| 68850 | 136 | fun setup_proof state after_qed propss eqns goal_ctxt = | 
| 137 | Element.witness_local_proof_eqs | |
| 138 | (fn witss => fn eqns => Proof.map_context (after_qed witss eqns) #> Proof.reset_facts) | |
| 139 | "interpret" propss eqns goal_ctxt state; | |
| 140 | ||
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 141 | fun gen_interpret prep_interpretation expression state = | 
| 68850 | 142 | Proof.assert_forward_or_chain state | 
| 143 | |> Proof.context_of | |
| 144 | |> generic_interpretation prep_interpretation (setup_proof state) | |
| 68852 | 145 | Attrib.local_notes Locale.add_registration_proof expression []; | 
| 61669 | 146 | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 147 | in | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 148 | |
| 63379 | 149 | val interpret = gen_interpret cert_interpretation; | 
| 150 | val interpret_cmd = gen_interpret read_interpretation; | |
| 61669 | 151 | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 152 | end; | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 153 | |
| 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 154 | |
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 155 | (* interpretation in local theories *) | 
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 156 | |
| 69050 | 157 | fun activate_fragment registration = | 
| 158 | Local_Theory.mark_brittle #> Locale.add_registration_local_theory registration; | |
| 159 | ||
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 160 | fun interpretation expression = | 
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 161 | generic_interpretation cert_interpretation Element.witness_proof_eqs | 
| 69050 | 162 | Local_Theory.notes_kind activate_fragment expression []; | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 163 | |
| 63380 | 164 | fun interpretation_cmd expression = | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 165 | generic_interpretation read_interpretation Element.witness_proof_eqs | 
| 69050 | 166 | Local_Theory.notes_kind activate_fragment expression []; | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 167 | |
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 168 | |
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 169 | (* interpretation into global theories *) | 
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 170 | |
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 171 | fun global_interpretation expression = | 
| 63380 | 172 | generic_interpretation cert_interpretation Element.witness_proof_eqs | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 173 | Local_Theory.notes_kind Local_Theory.theory_registration expression; | 
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 174 | |
| 63380 | 175 | fun global_interpretation_cmd expression = | 
| 176 | generic_interpretation read_interpretation Element.witness_proof_eqs | |
| 177 | Local_Theory.notes_kind Local_Theory.theory_registration expression; | |
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 178 | |
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 179 | |
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 180 | (* interpretation between locales *) | 
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 181 | |
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 182 | fun sublocale expression = | 
| 63380 | 183 | generic_interpretation cert_interpretation Element.witness_proof_eqs | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 184 | Local_Theory.notes_kind Local_Theory.locale_dependency expression; | 
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 185 | |
| 63380 | 186 | fun sublocale_cmd expression = | 
| 187 | generic_interpretation read_interpretation Element.witness_proof_eqs | |
| 188 | Local_Theory.notes_kind Local_Theory.locale_dependency expression; | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 189 | |
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 190 | local | 
| 61669 | 191 | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 192 | fun gen_global_sublocale prep_loc prep_interpretation | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 193 | raw_locale expression raw_defs thy = | 
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 194 | let | 
| 66334 
b210ae666a42
provide explicit variant initializers for regular named target vs. almost-named target
 haftmann parents: 
63402diff
changeset | 195 | val lthy = Named_Target.init (prep_loc thy raw_locale) thy; | 
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 196 | fun setup_proof after_qed = | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 197 | Element.witness_proof_eqs | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 198 | (fn wits => fn eqs => after_qed wits eqs #> Local_Theory.exit); | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 199 | in | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 200 | lthy |> | 
| 63380 | 201 | generic_interpretation prep_interpretation setup_proof | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 202 | Local_Theory.notes_kind Local_Theory.locale_dependency expression raw_defs | 
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 203 | end; | 
| 61669 | 204 | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 205 | in | 
| 61669 | 206 | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 207 | fun global_sublocale expression = | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 208 | gen_global_sublocale (K I) cert_interpretation expression; | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 209 | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 210 | fun global_sublocale_cmd raw_expression = | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 211 | gen_global_sublocale Locale.check read_interpretation raw_expression; | 
| 61669 | 212 | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 213 | end; | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 214 | |
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 215 | |
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 216 | (* mixed Isar interface *) | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 217 | |
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 218 | local | 
| 61670 
301e0b4ecd45
coalesce permanent_interpretation.ML with interpretation.ML
 haftmann parents: 
61669diff
changeset | 219 | |
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 220 | fun register_or_activate lthy = | 
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 221 | if Named_Target.is_theory lthy | 
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 222 | then Local_Theory.theory_registration | 
| 69050 | 223 | else activate_fragment; | 
| 61669 | 224 | |
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 225 | fun gen_isar_interpretation prep_interpretation expression lthy = | 
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 226 | generic_interpretation prep_interpretation Element.witness_proof_eqs | 
| 67777 
2d3c1091527b
Drop rewrite rule arguments of sublocale and interpretation implementations.
 ballarin parents: 
67740diff
changeset | 227 | Local_Theory.notes_kind (register_or_activate lthy) expression [] lthy; | 
| 61669 | 228 | |
| 61673 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 229 | in | 
| 
fd4ac1530d63
represent both algebraic and local-theory views on locale interpretation in interfaces
 haftmann parents: 
61672diff
changeset | 230 | |
| 61890 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 231 | fun isar_interpretation expression = | 
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 232 | gen_isar_interpretation cert_interpretation expression; | 
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 233 | fun isar_interpretation_cmd raw_expression = | 
| 
f6ded81f5690
abandoned attempt to unify sublocale and interpretation into global theories
 haftmann parents: 
61823diff
changeset | 234 | gen_isar_interpretation read_interpretation raw_expression; | 
| 61669 | 235 | |
| 236 | end; | |
| 237 | ||
| 238 | end; |