53 val eq_key = Thm.eq_thm; |
53 val eq_key = Thm.eq_thm; |
54 fun eq_data arg = eq_fst eq_key arg; |
54 fun eq_data arg = eq_fst eq_key arg; |
55 |
55 |
56 structure Data = Generic_Data |
56 structure Data = Generic_Data |
57 ( |
57 ( |
58 type T = simpset * (thm * entry) list; |
58 type T = (thm * entry) list; |
59 val empty = (HOL_basic_ss, []); |
59 val empty = []; |
60 val extend = I; |
60 val extend = I; |
61 fun merge ((ss, e), (ss', e')) : T = |
61 val merge = AList.merge eq_key (K true); |
62 (merge_ss (ss, ss'), AList.merge eq_key (K true) (e, e')); |
|
63 ); |
62 ); |
64 |
63 |
65 val get = snd o Data.get o Context.Proof; |
64 val get = Data.get o Context.Proof; |
66 |
65 |
67 |
66 |
68 (* match data *) |
67 (* match data *) |
69 |
68 |
70 fun match ctxt tm = |
69 fun match ctxt tm = |
108 val idealN = "ideal"; |
107 val idealN = "ideal"; |
109 val fieldN = "field"; |
108 val fieldN = "field"; |
110 |
109 |
111 fun undefined _ = raise Match; |
110 fun undefined _ = raise Match; |
112 |
111 |
113 fun del_data key = apsnd (remove eq_data (key, [])); |
112 fun del_data key = remove eq_data (key, []); |
114 |
113 |
115 val del = Thm.declaration_attribute (Data.map o del_data); |
114 val del = Thm.declaration_attribute (Data.map o del_data); |
116 |
115 |
117 fun add {semiring = (sr_ops, sr_rules), ring = (r_ops, r_rules), |
116 fun add {semiring = (sr_ops, sr_rules), ring = (r_ops, r_rules), |
118 field = (f_ops, f_rules), idom, ideal} = |
117 field = (f_ops, f_rules), idom, ideal} = |
157 val ring = (r_ops, r_rules'); |
156 val ring = (r_ops, r_rules'); |
158 val field = (f_ops, f_rules'); |
157 val field = (f_ops, f_rules'); |
159 val ideal' = map (symmetric o mk_meta) ideal |
158 val ideal' = map (symmetric o mk_meta) ideal |
160 in |
159 in |
161 del_data key #> |
160 del_data key #> |
162 apsnd (cons (key, ({vars = vars, semiring = semiring, |
161 cons (key, ({vars = vars, semiring = semiring, |
163 ring = ring, field = field, idom = idom, ideal = ideal'}, |
162 ring = ring, field = field, idom = idom, ideal = ideal'}, |
164 {is_const = undefined, dest_const = undefined, mk_const = undefined, |
163 {is_const = undefined, dest_const = undefined, mk_const = undefined, |
165 conv = undefined}))) |
164 conv = undefined})) |
166 end); |
165 end); |
167 |
166 |
168 |
167 |
169 (* extra-logical functions *) |
168 (* extra-logical functions *) |
170 |
169 |
171 fun funs raw_key {is_const, dest_const, mk_const, conv} phi = |
170 fun funs raw_key {is_const, dest_const, mk_const, conv} phi = |
172 (Data.map o apsnd) (fn data => |
171 Data.map (fn data => |
173 let |
172 let |
174 val key = Morphism.thm phi raw_key; |
173 val key = Morphism.thm phi raw_key; |
175 val _ = AList.defined eq_key data key orelse |
174 val _ = AList.defined eq_key data key orelse |
176 raise THM ("No data entry for structure key", 0, [key]); |
175 raise THM ("No data entry for structure key", 0, [key]); |
177 val fns = {is_const = is_const phi, dest_const = dest_const phi, |
176 val fns = {is_const = is_const phi, dest_const = dest_const phi, |