18 val map_name_of_ref: (string -> string) -> ref -> ref |
18 val map_name_of_ref: (string -> string) -> ref -> ref |
19 val select: ref -> thm list -> thm list |
19 val select: ref -> thm list -> thm list |
20 val selections: string * thm list -> (ref * thm) list |
20 val selections: string * thm list -> (ref * thm) list |
21 type T |
21 type T |
22 val empty: T |
22 val empty: T |
23 val space_of: T -> NameSpace.T |
23 val space_of: T -> Name_Space.T |
24 val intern: T -> xstring -> string |
24 val intern: T -> xstring -> string |
25 val extern: T -> string -> xstring |
25 val extern: T -> string -> xstring |
26 val lookup: Context.generic -> T -> string -> (bool * thm list) option |
26 val lookup: Context.generic -> T -> string -> (bool * thm list) option |
27 val defined: T -> string -> bool |
27 val defined: T -> string -> bool |
28 val fold_static: (string * thm list -> 'a -> 'a) -> T -> 'a -> 'a |
28 val fold_static: (string * thm list -> 'a -> 'a) -> T -> 'a -> 'a |
29 val dest_static: T list -> T -> (string * thm list) list |
29 val dest_static: T list -> T -> (string * thm list) list |
30 val extern_static: T list -> T -> (xstring * thm list) list |
30 val extern_static: T list -> T -> (xstring * thm list) list |
31 val props: T -> thm list |
31 val props: T -> thm list |
32 val could_unify: T -> term -> thm list |
32 val could_unify: T -> term -> thm list |
33 val merge: T * T -> T |
33 val merge: T * T -> T |
34 val add_global: NameSpace.naming -> binding * thm list -> T -> string * T |
34 val add_global: Name_Space.naming -> binding * thm list -> T -> string * T |
35 val add_local: bool -> NameSpace.naming -> binding * thm list -> T -> string * T |
35 val add_local: bool -> Name_Space.naming -> binding * thm list -> T -> string * T |
36 val add_dynamic: NameSpace.naming -> binding * (Context.generic -> thm list) -> T -> string * T |
36 val add_dynamic: Name_Space.naming -> binding * (Context.generic -> thm list) -> T -> string * T |
37 val del: string -> T -> T |
37 val del: string -> T -> T |
38 val hide: bool -> string -> T -> T |
38 val hide: bool -> string -> T -> T |
39 end; |
39 end; |
40 |
40 |
41 structure Facts: FACTS = |
41 structure Facts: FACTS = |
120 (* datatypes *) |
120 (* datatypes *) |
121 |
121 |
122 datatype fact = Static of thm list | Dynamic of Context.generic -> thm list; |
122 datatype fact = Static of thm list | Dynamic of Context.generic -> thm list; |
123 |
123 |
124 datatype T = Facts of |
124 datatype T = Facts of |
125 {facts: fact NameSpace.table, |
125 {facts: fact Name_Space.table, |
126 props: thm Net.net}; |
126 props: thm Net.net}; |
127 |
127 |
128 fun make_facts facts props = Facts {facts = facts, props = props}; |
128 fun make_facts facts props = Facts {facts = facts, props = props}; |
129 val empty = make_facts NameSpace.empty_table Net.empty; |
129 val empty = make_facts Name_Space.empty_table Net.empty; |
130 |
130 |
131 |
131 |
132 (* named facts *) |
132 (* named facts *) |
133 |
133 |
134 fun facts_of (Facts {facts, ...}) = facts; |
134 fun facts_of (Facts {facts, ...}) = facts; |
135 |
135 |
136 val space_of = #1 o facts_of; |
136 val space_of = #1 o facts_of; |
137 val table_of = #2 o facts_of; |
137 val table_of = #2 o facts_of; |
138 |
138 |
139 val intern = NameSpace.intern o space_of; |
139 val intern = Name_Space.intern o space_of; |
140 val extern = NameSpace.extern o space_of; |
140 val extern = Name_Space.extern o space_of; |
141 |
141 |
142 val defined = Symtab.defined o table_of; |
142 val defined = Symtab.defined o table_of; |
143 |
143 |
144 fun lookup context facts name = |
144 fun lookup context facts name = |
145 (case Symtab.lookup (table_of facts) name of |
145 (case Symtab.lookup (table_of facts) name of |
175 |
175 |
176 (* merge facts *) |
176 (* merge facts *) |
177 |
177 |
178 fun merge (Facts {facts = facts1, props = props1}, Facts {facts = facts2, props = props2}) = |
178 fun merge (Facts {facts = facts1, props = props1}, Facts {facts = facts2, props = props2}) = |
179 let |
179 let |
180 val facts' = NameSpace.merge_tables (facts1, facts2); |
180 val facts' = Name_Space.merge_tables (facts1, facts2); |
181 val props' = Net.merge (is_equal o prop_ord) (props1, props2); |
181 val props' = Net.merge (is_equal o prop_ord) (props1, props2); |
182 in make_facts facts' props' end; |
182 in make_facts facts' props' end; |
183 |
183 |
184 |
184 |
185 (* add static entries *) |
185 (* add static entries *) |
188 |
188 |
189 fun add strict do_props naming (b, ths) (Facts {facts, props}) = |
189 fun add strict do_props naming (b, ths) (Facts {facts, props}) = |
190 let |
190 let |
191 val (name, facts') = |
191 val (name, facts') = |
192 if Binding.is_empty b then ("", facts) |
192 if Binding.is_empty b then ("", facts) |
193 else NameSpace.define strict naming (b, Static ths) facts; |
193 else Name_Space.define strict naming (b, Static ths) facts; |
194 val props' = |
194 val props' = |
195 if do_props |
195 if do_props |
196 then fold (fn th => Net.insert_term (K false) (Thm.full_prop_of th, th)) ths props |
196 then fold (fn th => Net.insert_term (K false) (Thm.full_prop_of th, th)) ths props |
197 else props; |
197 else props; |
198 in (name, make_facts facts' props') end; |
198 in (name, make_facts facts' props') end; |
206 |
206 |
207 |
207 |
208 (* add dynamic entries *) |
208 (* add dynamic entries *) |
209 |
209 |
210 fun add_dynamic naming (b, f) (Facts {facts, props}) = |
210 fun add_dynamic naming (b, f) (Facts {facts, props}) = |
211 let val (name, facts') = NameSpace.define true naming (b, Dynamic f) facts; |
211 let val (name, facts') = Name_Space.define true naming (b, Dynamic f) facts; |
212 in (name, make_facts facts' props) end; |
212 in (name, make_facts facts' props) end; |
213 |
213 |
214 |
214 |
215 (* remove entries *) |
215 (* remove entries *) |
216 |
216 |
217 fun del name (Facts {facts = (space, tab), props}) = |
217 fun del name (Facts {facts = (space, tab), props}) = |
218 let |
218 let |
219 val space' = NameSpace.hide true name space handle ERROR _ => space; (* FIXME handle?? *) |
219 val space' = Name_Space.hide true name space handle ERROR _ => space; (* FIXME handle?? *) |
220 val tab' = Symtab.delete_safe name tab; |
220 val tab' = Symtab.delete_safe name tab; |
221 in make_facts (space', tab') props end; |
221 in make_facts (space', tab') props end; |
222 |
222 |
223 fun hide fully name (Facts {facts = (space, tab), props}) = |
223 fun hide fully name (Facts {facts = (space, tab), props}) = |
224 make_facts (NameSpace.hide fully name space, tab) props; |
224 make_facts (Name_Space.hide fully name space, tab) props; |
225 |
225 |
226 end; |
226 end; |