194 (Name_Space.dest_table (#types rep_tsig)); |
194 (Name_Space.dest_table (#types rep_tsig)); |
195 |
195 |
196 |
196 |
197 (* consts *) |
197 (* consts *) |
198 |
198 |
|
199 val consts = Sign.consts_of thy; |
|
200 val encode_term = Term_XML.Encode.term consts; |
|
201 |
199 val encode_const = |
202 val encode_const = |
200 let open XML.Encode Term_XML.Encode in |
203 let open XML.Encode Term_XML.Encode in |
201 pair encode_syntax |
204 pair encode_syntax |
202 (pair (list string) |
205 (pair (list string) |
203 (pair typ (pair (option term) (pair bool (pair (list string) bool))))) |
206 (pair typ (pair (option encode_term) (pair bool (pair (list string) bool))))) |
204 end; |
207 end; |
205 |
208 |
206 fun export_const c (T, abbrev) = |
209 fun export_const c (T, abbrev) = |
207 let |
210 let |
208 val syntax = get_syntax_const thy_ctxt c; |
211 val syntax = get_syntax_const thy_ctxt c; |
209 val U = Logic.unvarifyT_global T; |
212 val U = Logic.unvarifyT_global T; |
210 val U0 = Type.strip_sorts U; |
213 val U0 = Type.strip_sorts U; |
211 val recursion = primrec_types thy_ctxt (c, U); |
214 val recursion = primrec_types thy_ctxt (c, U); |
212 val abbrev' = abbrev |
215 val abbrev' = abbrev |
213 |> Option.map (Proofterm.standard_vars_term Name.context #> map_types Type.strip_sorts); |
216 |> Option.map (Proofterm.standard_vars_term Name.context #> map_types Type.strip_sorts); |
214 val args = map (#1 o dest_TFree) (Consts.typargs (Sign.consts_of thy) (c, U0)); |
217 val args = map (#1 o dest_TFree) (Consts.typargs consts (c, U0)); |
215 val propositional = Object_Logic.is_propositional thy_ctxt (Term.body_type U0); |
218 val propositional = Object_Logic.is_propositional thy_ctxt (Term.body_type U0); |
216 in encode_const (syntax, (args, (U0, (abbrev', (propositional, recursion))))) end; |
219 in encode_const (syntax, (args, (U0, (abbrev', (propositional, recursion))))) end; |
217 |
220 |
218 val _ = |
221 val _ = |
219 export_entities "consts" (SOME oo export_const) Sign.const_space |
222 export_entities "consts" (SOME oo export_const) Sign.const_space |
220 (#constants (Consts.dest (Sign.consts_of thy))); |
223 (#constants (Consts.dest consts)); |
221 |
224 |
222 |
225 |
223 (* axioms *) |
226 (* axioms *) |
224 |
227 |
225 fun standard_prop used extra_shyps raw_prop raw_proof = |
228 fun standard_prop used extra_shyps raw_prop raw_proof = |
231 val sorts = Name.invent used_typargs Name.aT (length extra_shyps) ~~ extra_shyps; |
234 val sorts = Name.invent used_typargs Name.aT (length extra_shyps) ~~ extra_shyps; |
232 in ((sorts @ typargs, args, prop), proof) end; |
235 in ((sorts @ typargs, args, prop), proof) end; |
233 |
236 |
234 val encode_prop = |
237 val encode_prop = |
235 let open XML.Encode Term_XML.Encode |
238 let open XML.Encode Term_XML.Encode |
236 in triple (list (pair string sort)) (list (pair string typ)) term end; |
239 in triple (list (pair string sort)) (list (pair string typ)) encode_term end; |
237 |
240 |
238 fun encode_axiom used prop = |
241 fun encode_axiom used prop = |
239 encode_prop (#1 (standard_prop used [] prop NONE)); |
242 encode_prop (#1 (standard_prop used [] prop NONE)); |
240 |
243 |
241 val _ = |
244 val _ = |
266 val (prop, proof) = |
269 val (prop, proof) = |
267 standard_prop Name.context (Thm.extra_shyps thm) (Thm.full_prop_of thm) (SOME raw_proof); |
270 standard_prop Name.context (Thm.extra_shyps thm) (Thm.full_prop_of thm) (SOME raw_proof); |
268 in |
271 in |
269 (prop, (deps, proof)) |> |
272 (prop, (deps, proof)) |> |
270 let open XML.Encode Term_XML.Encode |
273 let open XML.Encode Term_XML.Encode |
271 in pair encode_prop (pair (list string) (option Proofterm.encode_full)) end |
274 in pair encode_prop (pair (list string) (option (Proofterm.encode_full consts))) end |
272 end; |
275 end; |
273 |
276 |
274 fun buffer_export_thm (serial, thm_name) = |
277 fun buffer_export_thm (serial, thm_name) = |
275 let |
278 let |
276 val markup = entity_markup_thm (serial, thm_name); |
279 val markup = entity_markup_thm (serial, thm_name); |
354 fun encode_locale_dependency (dep: Locale.locale_dependency, subst) = |
357 fun encode_locale_dependency (dep: Locale.locale_dependency, subst) = |
355 (#source dep, (#target dep, (#prefix dep, subst))) |> |
358 (#source dep, (#target dep, (#prefix dep, subst))) |> |
356 let |
359 let |
357 open XML.Encode Term_XML.Encode; |
360 open XML.Encode Term_XML.Encode; |
358 val encode_subst = |
361 val encode_subst = |
359 pair (list (pair (pair string sort) typ)) (list (pair (pair string typ) term)); |
362 pair (list (pair (pair string sort) typ)) (list (pair (pair string typ) (term consts))); |
360 in pair string (pair string (pair (list (pair string bool)) encode_subst)) end; |
363 in pair string (pair string (pair (list (pair string bool)) encode_subst)) end; |
361 |
364 |
362 val _ = |
365 val _ = |
363 get_dependencies parents thy |
366 get_dependencies parents thy |
364 |> map_index (fn (i, dep) => |
367 |> map_index (fn (i, dep) => |