author | haftmann |
Mon, 01 Dec 2008 16:02:57 +0100 | |
changeset 28940 | df0cb410be35 |
parent 28927 | 7e631979922f |
child 28951 | e89dde5f365c |
permissions | -rw-r--r-- |
28795 | 1 |
(* Title: Pure/Isar/expression.ML |
2 |
ID: $Id$ |
|
3 |
Author: Clemens Ballarin, TU Muenchen |
|
4 |
||
5 |
New locale development --- experimental. |
|
6 |
*) |
|
7 |
||
8 |
signature NEW_LOCALE = |
|
9 |
sig |
|
28872 | 10 |
type identifiers |
11 |
val empty: identifiers |
|
12 |
||
28795 | 13 |
type locale |
14 |
||
15 |
val test_locale: theory -> string -> bool |
|
16 |
val register_locale: string -> |
|
17 |
(string * sort) list * (Name.binding * typ option * mixfix) list -> |
|
18 |
term option * term list -> |
|
19 |
(declaration * stamp) list * (declaration * stamp) list -> |
|
20 |
((string * (Attrib.binding * (thm list * Attrib.src list) list) list) * stamp) list -> |
|
21 |
((string * Morphism.morphism) * stamp) list -> theory -> theory |
|
22 |
||
23 |
(* Locale name space *) |
|
24 |
val intern: theory -> xstring -> string |
|
25 |
val extern: theory -> string -> xstring |
|
26 |
||
27 |
(* Specification *) |
|
28 |
val params_of: theory -> string -> (Name.binding * typ option * mixfix) list |
|
28872 | 29 |
val specification_of: theory -> string -> term option * term list |
30 |
val declarations_of: theory -> string -> declaration list * declaration list |
|
28795 | 31 |
|
28818 | 32 |
(* Storing results *) |
28833 | 33 |
val add_thmss: string -> string -> (Attrib.binding * (thm list * Attrib.src list) list) list -> |
28818 | 34 |
Proof.context -> Proof.context |
35 |
val add_type_syntax: string -> declaration -> Proof.context -> Proof.context |
|
36 |
val add_term_syntax: string -> declaration -> Proof.context -> Proof.context |
|
37 |
val add_declaration: string -> declaration -> Proof.context -> Proof.context |
|
28894
ff724071b902
Command to add dependencies, fixed processing of dependencies.
ballarin
parents:
28878
diff
changeset
|
38 |
val add_dependency: string -> (string * Morphism.morphism) -> Proof.context -> Proof.context |
28818 | 39 |
|
28903
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
40 |
(* Activation *) |
28878 | 41 |
val activate_declarations: theory -> string * Morphism.morphism -> |
42 |
identifiers * Proof.context -> identifiers * Proof.context |
|
43 |
val activate_facts: theory -> string * Morphism.morphism -> |
|
44 |
identifiers * Proof.context -> identifiers * Proof.context |
|
45 |
(* val activate: string -> theory -> (Element.context_i -> 'a -> 'a) -> 'a -> 'a *) |
|
28795 | 46 |
val init: string -> theory -> Proof.context |
47 |
||
28903
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
48 |
(* Reasoning about locales *) |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
49 |
val witness_attrib: attribute |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
50 |
val intro_attrib: attribute |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
51 |
val unfold_attrib: attribute |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
52 |
val intro_locales_tac: bool -> Proof.context -> thm list -> tactic |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
53 |
|
28795 | 54 |
(* Diagnostic *) |
55 |
val print_locales: theory -> unit |
|
56 |
val print_locale: theory -> bool -> bstring -> unit |
|
57 |
end; |
|
58 |
||
59 |
||
28903
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
60 |
(* FIXME: consider moving named_thms.ML up in the build hierarchy and using that *) |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
61 |
functor ThmsFun() = |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
62 |
struct |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
63 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
64 |
structure Data = GenericDataFun |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
65 |
( |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
66 |
type T = thm list; |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
67 |
val empty = []; |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
68 |
val extend = I; |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
69 |
fun merge _ = Thm.merge_thms; |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
70 |
); |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
71 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
72 |
val get = Data.get o Context.Proof; |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
73 |
val add = Thm.declaration_attribute (Data.map o Thm.add_thm); |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
74 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
75 |
end; |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
76 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
77 |
|
28795 | 78 |
structure NewLocale: NEW_LOCALE = |
79 |
struct |
|
80 |
||
81 |
datatype ctxt = datatype Element.ctxt; |
|
82 |
||
83 |
||
84 |
(*** Basics ***) |
|
85 |
||
86 |
datatype locale = Loc of { |
|
87 |
(* extensible lists are in reverse order: decls, notes, dependencies *) |
|
88 |
parameters: (string * sort) list * (Name.binding * typ option * mixfix) list, |
|
89 |
(* type and term parameters *) |
|
90 |
spec: term option * term list, |
|
91 |
(* assumptions (as a single predicate expression) and defines *) |
|
92 |
decls: (declaration * stamp) list * (declaration * stamp) list, |
|
93 |
(* type and term syntax declarations *) |
|
94 |
notes: ((string * (Attrib.binding * (thm list * Attrib.src list) list) list) * stamp) list, |
|
95 |
(* theorem declarations *) |
|
96 |
dependencies: ((string * Morphism.morphism) * stamp) list |
|
97 |
(* locale dependencies (sublocale relation) *) |
|
98 |
} |
|
99 |
||
100 |
||
101 |
(*** Theory data ***) |
|
102 |
||
103 |
structure LocalesData = TheoryDataFun |
|
104 |
( |
|
105 |
type T = NameSpace.T * locale Symtab.table; |
|
106 |
(* locale namespace and locales of the theory *) |
|
107 |
||
108 |
val empty = (NameSpace.empty, Symtab.empty); |
|
109 |
val copy = I; |
|
110 |
val extend = I; |
|
111 |
||
112 |
fun join_locales _ |
|
113 |
(Loc {parameters, spec, decls = (decls1, decls2), notes, dependencies}, |
|
114 |
Loc {decls = (decls1', decls2'), notes = notes', |
|
115 |
dependencies = dependencies', ...}) = |
|
116 |
let fun s_merge x = merge (eq_snd (op =)) x in |
|
117 |
Loc {parameters = parameters, |
|
118 |
spec = spec, |
|
119 |
decls = (s_merge (decls1, decls1'), s_merge (decls2, decls2')), |
|
120 |
notes = s_merge (notes, notes'), |
|
121 |
dependencies = s_merge (dependencies, dependencies') |
|
122 |
} |
|
123 |
end; |
|
124 |
fun merge _ ((space1, locs1), (space2, locs2)) = |
|
125 |
(NameSpace.merge (space1, space2), Symtab.join join_locales (locs1, locs2)); |
|
126 |
); |
|
127 |
||
128 |
val intern = NameSpace.intern o #1 o LocalesData.get; |
|
129 |
val extern = NameSpace.extern o #1 o LocalesData.get; |
|
130 |
||
131 |
fun get_locale thy name = Symtab.lookup (#2 (LocalesData.get thy)) name; |
|
132 |
||
133 |
fun the_locale thy name = case get_locale thy name |
|
134 |
of SOME loc => loc |
|
135 |
| NONE => error ("Unknown locale " ^ quote name); |
|
136 |
||
137 |
fun test_locale thy name = case get_locale thy name |
|
138 |
of SOME _ => true | NONE => false; |
|
139 |
||
140 |
fun register_locale name parameters spec decls notes dependencies thy = |
|
141 |
thy |> LocalesData.map (fn (space, locs) => |
|
142 |
(Sign.declare_name thy name space, Symtab.update (name, |
|
143 |
Loc {parameters = parameters, spec = spec, decls = decls, notes = notes, |
|
144 |
dependencies = dependencies}) locs)); |
|
145 |
||
146 |
fun change_locale name f thy = |
|
147 |
let |
|
148 |
val Loc {parameters, spec, decls, notes, dependencies} = |
|
149 |
the_locale thy name; |
|
150 |
val (parameters', spec', decls', notes', dependencies') = |
|
151 |
f (parameters, spec, decls, notes, dependencies); |
|
152 |
in |
|
153 |
thy |
|
154 |
|> (LocalesData.map o apsnd) (Symtab.update (name, Loc {parameters = parameters', |
|
155 |
spec = spec', decls = decls', notes = notes', dependencies = dependencies'})) |
|
156 |
end; |
|
157 |
||
158 |
fun print_locales thy = |
|
159 |
let val (space, locs) = LocalesData.get thy in |
|
160 |
Pretty.strs ("locales:" :: map #1 (NameSpace.extern_table (space, locs))) |
|
161 |
|> Pretty.writeln |
|
162 |
end; |
|
163 |
||
164 |
||
165 |
(*** Primitive operations ***) |
|
166 |
||
167 |
fun params_of thy name = |
|
168 |
let |
|
169 |
val Loc {parameters = (_, params), ...} = the_locale thy name |
|
170 |
in params end; |
|
171 |
||
28872 | 172 |
fun specification_of thy name = |
28795 | 173 |
let |
28872 | 174 |
val Loc {spec, ...} = the_locale thy name |
175 |
in spec end; |
|
176 |
||
177 |
fun declarations_of thy name = |
|
178 |
let |
|
179 |
val Loc {decls, ...} = the_locale thy name |
|
28795 | 180 |
in |
181 |
decls |> apfst (map fst) |> apsnd (map fst) |
|
182 |
end; |
|
183 |
||
184 |
||
28818 | 185 |
(*** Activate context elements of locale ***) |
28795 | 186 |
|
28897 | 187 |
(** Resolve locale dependencies in a depth-first fashion **) |
28795 | 188 |
|
28899
7bf5d7f154b8
Perform higher-order pattern matching during round-up.
ballarin
parents:
28897
diff
changeset
|
189 |
type identifiers = (string * term list) list; |
7bf5d7f154b8
Perform higher-order pattern matching during round-up.
ballarin
parents:
28897
diff
changeset
|
190 |
|
7bf5d7f154b8
Perform higher-order pattern matching during round-up.
ballarin
parents:
28897
diff
changeset
|
191 |
val empty = ([] : identifiers); |
7bf5d7f154b8
Perform higher-order pattern matching during round-up.
ballarin
parents:
28897
diff
changeset
|
192 |
|
28795 | 193 |
local |
194 |
||
28899
7bf5d7f154b8
Perform higher-order pattern matching during round-up.
ballarin
parents:
28897
diff
changeset
|
195 |
fun ident_eq thy ((n, ts), (m, ss)) = (m = n) andalso Pattern.matchess thy (ss, ts); |
28872 | 196 |
|
28897 | 197 |
val roundup_bound = 120; |
198 |
||
199 |
fun add thy depth (name, morph) (deps, marked) = |
|
200 |
if depth > roundup_bound |
|
201 |
then error "Roundup bound exceeded (sublocale relation probably not terminating)." |
|
202 |
else |
|
203 |
let |
|
204 |
val Loc {parameters = (_, params), dependencies, ...} = the_locale thy name; |
|
205 |
val instance = params |> |
|
206 |
map ((fn (b, T, _) => Free (Name.name_of b, the T)) #> Morphism.term morph); |
|
207 |
in |
|
28899
7bf5d7f154b8
Perform higher-order pattern matching during round-up.
ballarin
parents:
28897
diff
changeset
|
208 |
if member (ident_eq thy) marked (name, instance) |
28897 | 209 |
then (deps, marked) |
210 |
else |
|
211 |
let |
|
212 |
val dependencies' = |
|
213 |
map (fn ((name, morph'), _) => (name, morph' $> morph)) dependencies; |
|
28899
7bf5d7f154b8
Perform higher-order pattern matching during round-up.
ballarin
parents:
28897
diff
changeset
|
214 |
val marked' = (name, instance) :: marked; |
28897 | 215 |
val (deps', marked'') = fold_rev (add thy (depth + 1)) dependencies' ([], marked'); |
216 |
in |
|
217 |
((name, morph) :: deps' @ deps, marked'') |
|
218 |
end |
|
219 |
end; |
|
220 |
||
221 |
in |
|
222 |
||
223 |
fun roundup thy activate_dep (name, morph) (marked, ctxt) = |
|
28795 | 224 |
let |
28902
2019bcc9d8bf
Ahere to modern naming conventions; proper treatment of internal vs external names.
ballarin
parents:
28899
diff
changeset
|
225 |
val Loc {dependencies, ...} = the_locale thy name; |
2019bcc9d8bf
Ahere to modern naming conventions; proper treatment of internal vs external names.
ballarin
parents:
28899
diff
changeset
|
226 |
val (dependencies', marked') = add thy 0 (name, morph) ([], marked); |
28894
ff724071b902
Command to add dependencies, fixed processing of dependencies.
ballarin
parents:
28878
diff
changeset
|
227 |
in |
28897 | 228 |
(marked', ctxt |> fold_rev (activate_dep thy) dependencies') |
28894
ff724071b902
Command to add dependencies, fixed processing of dependencies.
ballarin
parents:
28878
diff
changeset
|
229 |
end; |
28795 | 230 |
|
231 |
end; |
|
232 |
||
28897 | 233 |
|
234 |
(* Declarations and facts *) |
|
28795 | 235 |
|
28818 | 236 |
fun activate_decls thy (name, morph) ctxt = |
237 |
let |
|
238 |
val Loc {decls = (typ_decls, term_decls), ...} = the_locale thy name; |
|
239 |
in |
|
240 |
ctxt |> fold_rev (fn (decl, _) => Context.proof_map (decl morph)) typ_decls |> |
|
241 |
fold_rev (fn (decl, _) => Context.proof_map (decl morph)) term_decls |
|
242 |
end; |
|
28795 | 243 |
|
28818 | 244 |
fun activate_notes activ_elem thy (name, morph) input = |
245 |
let |
|
246 |
val Loc {notes, ...} = the_locale thy name; |
|
247 |
fun activate ((kind, facts), _) input = |
|
28795 | 248 |
let |
28818 | 249 |
val facts' = facts |> Element.facts_map (Element.morph_ctxt morph) |
250 |
in activ_elem (Notes (kind, facts')) input end; |
|
28795 | 251 |
in |
28818 | 252 |
fold_rev activate notes input |
28795 | 253 |
end; |
254 |
||
28897 | 255 |
|
256 |
(* Entire locale content *) |
|
28878 | 257 |
|
28818 | 258 |
fun activate name thy activ_elem input = |
28795 | 259 |
let |
260 |
val Loc {parameters = (_, params), spec = (asm, defs), dependencies, ...} = |
|
28902
2019bcc9d8bf
Ahere to modern naming conventions; proper treatment of internal vs external names.
ballarin
parents:
28899
diff
changeset
|
261 |
the_locale thy name; |
28795 | 262 |
in |
28818 | 263 |
input |> |
28851
368aca388dd9
Use 'if' in connection with 'is_some' and 'the'.
ballarin
parents:
28833
diff
changeset
|
264 |
(if not (null params) then activ_elem (Fixes params) else I) |> |
28795 | 265 |
(* FIXME type parameters *) |
28851
368aca388dd9
Use 'if' in connection with 'is_some' and 'the'.
ballarin
parents:
28833
diff
changeset
|
266 |
(if is_some asm then activ_elem (Assumes [(Attrib.no_binding, [(the asm, [])])]) else I) |> |
368aca388dd9
Use 'if' in connection with 'is_some' and 'the'.
ballarin
parents:
28833
diff
changeset
|
267 |
(if not (null defs) |
368aca388dd9
Use 'if' in connection with 'is_some' and 'the'.
ballarin
parents:
28833
diff
changeset
|
268 |
then activ_elem (Defines (map (fn def => (Attrib.no_binding, (def, []))) defs)) |
368aca388dd9
Use 'if' in connection with 'is_some' and 'the'.
ballarin
parents:
28833
diff
changeset
|
269 |
else I) |> |
28902
2019bcc9d8bf
Ahere to modern naming conventions; proper treatment of internal vs external names.
ballarin
parents:
28899
diff
changeset
|
270 |
pair empty |> roundup thy (activate_notes activ_elem) (name, Morphism.identity) |> snd |
28795 | 271 |
end; |
272 |
||
28897 | 273 |
|
274 |
(** Public activation functions **) |
|
275 |
||
28818 | 276 |
local |
277 |
||
278 |
fun init_elem (Fixes fixes) ctxt = ctxt |> |
|
279 |
ProofContext.add_fixes_i fixes |> snd |
|
280 |
| init_elem (Assumes assms) ctxt = |
|
281 |
let |
|
282 |
val assms' = Attrib.map_specs (Attrib.attribute_i (ProofContext.theory_of ctxt)) assms |
|
283 |
in |
|
284 |
ctxt |> fold Variable.auto_fixes (maps (map fst o snd) assms') |> |
|
285 |
ProofContext.add_assms_i Assumption.assume_export assms' |> snd |
|
286 |
end |
|
287 |
| init_elem (Defines defs) ctxt = |
|
288 |
let |
|
289 |
val defs' = Attrib.map_specs (Attrib.attribute_i (ProofContext.theory_of ctxt)) defs |
|
290 |
in |
|
291 |
ctxt |> fold Variable.auto_fixes (map (fst o snd) defs') |> |
|
292 |
ProofContext.add_assms_i LocalDefs.def_export (map (fn (attn, t) => (attn, [t])) defs') |> |
|
293 |
snd |
|
294 |
end |
|
295 |
| init_elem (Notes (kind, facts)) ctxt = |
|
296 |
let |
|
297 |
val facts' = Attrib.map_facts (Attrib.attribute_i (ProofContext.theory_of ctxt)) facts |
|
28940 | 298 |
in Locale.local_note_qualified kind facts' ctxt |> snd end |
28818 | 299 |
|
300 |
fun cons_elem false (Notes notes) elems = elems |
|
301 |
| cons_elem _ elem elems = elem :: elems |
|
302 |
||
303 |
in |
|
304 |
||
28897 | 305 |
fun activate_declarations thy = roundup thy activate_decls; |
306 |
||
307 |
fun activate_facts thy = roundup thy (activate_notes init_elem); |
|
28878 | 308 |
|
28818 | 309 |
fun init name thy = activate name thy init_elem (ProofContext.init thy); |
310 |
||
28795 | 311 |
fun print_locale thy show_facts name = |
28902
2019bcc9d8bf
Ahere to modern naming conventions; proper treatment of internal vs external names.
ballarin
parents:
28899
diff
changeset
|
312 |
let |
2019bcc9d8bf
Ahere to modern naming conventions; proper treatment of internal vs external names.
ballarin
parents:
28899
diff
changeset
|
313 |
val name' = intern thy name; |
2019bcc9d8bf
Ahere to modern naming conventions; proper treatment of internal vs external names.
ballarin
parents:
28899
diff
changeset
|
314 |
val ctxt = init name' thy |
28795 | 315 |
in |
316 |
Pretty.big_list "locale elements:" |
|
28902
2019bcc9d8bf
Ahere to modern naming conventions; proper treatment of internal vs external names.
ballarin
parents:
28899
diff
changeset
|
317 |
(activate name' thy (cons_elem show_facts) [] |> rev |> |
28818 | 318 |
map (Element.pretty_ctxt ctxt) |> map Pretty.chunks) |> Pretty.writeln |
319 |
end |
|
28795 | 320 |
|
321 |
end; |
|
322 |
||
323 |
||
28818 | 324 |
(*** Storing results ***) |
325 |
||
28833 | 326 |
(* Theorems *) |
327 |
||
328 |
fun add_thmss loc kind args ctxt = |
|
329 |
let |
|
330 |
val (([Notes args'], _), ctxt') = Element.activate_i [Notes (kind, args)] ctxt; |
|
331 |
val ctxt'' = ctxt' |> ProofContext.theory |
|
332 |
(change_locale loc |
|
333 |
(fn (parameters, spec, decls, notes, dependencies) => |
|
334 |
(parameters, spec, decls, (args', stamp ()) :: notes, dependencies))) |
|
335 |
(* FIXME registrations *) |
|
336 |
in ctxt'' end; |
|
337 |
||
338 |
||
28818 | 339 |
(* Declarations *) |
340 |
||
341 |
local |
|
342 |
||
343 |
fun decl_attrib decl phi = Thm.declaration_attribute (K (decl phi)); |
|
344 |
||
345 |
fun add_decls add loc decl = |
|
346 |
ProofContext.theory (change_locale loc |
|
347 |
(fn (parameters, spec, decls, notes, dependencies) => |
|
28833 | 348 |
(parameters, spec, add (decl, stamp ()) decls, notes, dependencies))) #> |
28818 | 349 |
add_thmss loc Thm.internalK |
350 |
[((Name.no_binding, [Attrib.internal (decl_attrib decl)]), [([Drule.dummy_thm], [])])]; |
|
351 |
||
352 |
in |
|
353 |
||
354 |
val add_type_syntax = add_decls (apfst o cons); |
|
355 |
val add_term_syntax = add_decls (apsnd o cons); |
|
356 |
val add_declaration = add_decls (K I); |
|
357 |
||
358 |
end; |
|
359 |
||
28894
ff724071b902
Command to add dependencies, fixed processing of dependencies.
ballarin
parents:
28878
diff
changeset
|
360 |
(* Dependencies *) |
ff724071b902
Command to add dependencies, fixed processing of dependencies.
ballarin
parents:
28878
diff
changeset
|
361 |
|
ff724071b902
Command to add dependencies, fixed processing of dependencies.
ballarin
parents:
28878
diff
changeset
|
362 |
fun add_dependency loc dep = |
ff724071b902
Command to add dependencies, fixed processing of dependencies.
ballarin
parents:
28878
diff
changeset
|
363 |
ProofContext.theory (change_locale loc |
ff724071b902
Command to add dependencies, fixed processing of dependencies.
ballarin
parents:
28878
diff
changeset
|
364 |
(fn (parameters, spec, decls, notes, dependencies) => |
ff724071b902
Command to add dependencies, fixed processing of dependencies.
ballarin
parents:
28878
diff
changeset
|
365 |
(parameters, spec, decls, notes, (dep, stamp ()) :: dependencies))); |
ff724071b902
Command to add dependencies, fixed processing of dependencies.
ballarin
parents:
28878
diff
changeset
|
366 |
|
28903
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
367 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
368 |
(*** Reasoning about locales ***) |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
369 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
370 |
(** Storage for witnesses, intro and unfold rules **) |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
371 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
372 |
structure Witnesses = ThmsFun(); |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
373 |
structure Intros = ThmsFun(); |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
374 |
structure Unfolds = ThmsFun(); |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
375 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
376 |
val witness_attrib = Witnesses.add; |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
377 |
val intro_attrib = Intros.add; |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
378 |
val unfold_attrib = Unfolds.add; |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
379 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
380 |
(** Tactic **) |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
381 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
382 |
fun intro_locales_tac eager ctxt facts st = |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
383 |
Method.intros_tac |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
384 |
(Witnesses.get ctxt @ Intros.get ctxt @ (if eager then Unfolds.get ctxt else [])) facts st; |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
385 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
386 |
val _ = Context.>> (Context.map_theory |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
387 |
(Method.add_methods |
28927
7e631979922f
Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents:
28903
diff
changeset
|
388 |
[("intro_locales", |
7e631979922f
Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents:
28903
diff
changeset
|
389 |
Method.ctxt_args (fn ctxt => Method.METHOD (intro_locales_tac false ctxt ORELSE' |
7e631979922f
Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents:
28903
diff
changeset
|
390 |
Locale.intro_locales_tac false ctxt)), |
28903
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
391 |
"back-chain introduction rules of locales without unfolding predicates"), |
28927
7e631979922f
Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents:
28903
diff
changeset
|
392 |
("unfold_locales", |
7e631979922f
Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents:
28903
diff
changeset
|
393 |
Method.ctxt_args (fn ctxt => Method.METHOD (intro_locales_tac true ctxt ORELSE' |
7e631979922f
Methods intro_locales and unfold_locales apply to both old and new locales.
ballarin
parents:
28903
diff
changeset
|
394 |
Locale.intro_locales_tac true ctxt)), |
28903
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
395 |
"back-chain all introduction rules of locales")])); |
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
396 |
|
b3fc3a62247a
Intro_locales_tac to simplify goals involving locale predicates.
ballarin
parents:
28902
diff
changeset
|
397 |
|
28818 | 398 |
end; |
399 |