368 |> Locale.interpretation I (prfx, atts) expr (map (Option.map ad_hoc_term) insts) |
368 |> Locale.interpretation I (prfx, atts) expr (map (Option.map ad_hoc_term) insts) |
369 |> Proof.global_terminal_proof (Method.Basic (fn _ => Method.SIMPLE_METHOD tac), NONE) |
369 |> Proof.global_terminal_proof (Method.Basic (fn _ => Method.SIMPLE_METHOD tac), NONE) |
370 |> ProofContext.theory_of |
370 |> ProofContext.theory_of |
371 end; |
371 end; |
372 |
372 |
373 (* |
|
374 fun gen_class add_locale prep_class bname raw_supclasses raw_elems thy = |
373 fun gen_class add_locale prep_class bname raw_supclasses raw_elems thy = |
375 let |
374 let |
376 val elems = fold_rev (fn Locale.Elem e => cons e | _ => I) raw_elems []; |
375 val elems = fold_rev (fn Locale.Elem e => cons e | _ => I) raw_elems []; |
377 val supclasses = map (prep_class thy) raw_supclasses; |
376 val supclasses = map (prep_class thy) raw_supclasses; |
378 val supsort = |
377 val supsort = |
401 Locale.parameters_of thy name_locale |
400 Locale.parameters_of thy name_locale |
402 |> (map o apfst o apsnd o Term.map_type_tfree) (K (TFree (AxClass.param_tyvarname, []))) |
401 |> (map o apfst o apsnd o Term.map_type_tfree) (K (TFree (AxClass.param_tyvarname, []))) |
403 |> (map o apsnd) (TheoryTarget.fork_mixfix false true #> fst) |
402 |> (map o apsnd) (TheoryTarget.fork_mixfix false true #> fst) |
404 |> chop (length supconsts) |
403 |> chop (length supconsts) |
405 |> snd; |
404 |> snd; |
406 val LOC_AXIOMS = ref [] : string list ref; |
|
407 fun extract_assumes name_locale params thy cs = |
405 fun extract_assumes name_locale params thy cs = |
408 let |
406 let |
409 val consts = supconsts @ (map (fst o fst) params ~~ cs); |
407 val consts = supconsts @ (map (fst o fst) params ~~ cs); |
410 (*FIXME is this type handling correct?*) |
408 (*FIXME is this type handling correct?*) |
411 fun subst (Free (c, ty)) = |
409 fun subst (Free (c, ty)) = |
412 Const ((fst o the o AList.lookup (op =) consts) c, ty); |
410 Const ((fst o the o AList.lookup (op =) consts) c, ty) |
|
411 | subst t = t; |
413 fun prep_asm ((name, atts), ts) = |
412 fun prep_asm ((name, atts), ts) = |
414 (*FIXME*) |
413 (*FIXME*) |
415 ((NameSpace.base name, map (Attrib.attribute thy) atts), (map o map_aterms) subst ts); |
414 ((NameSpace.base name, map (Attrib.attribute thy) atts), (map o map_aterms) subst ts); |
416 in |
415 in |
417 Locale.local_asms_of thy name_locale |
416 Locale.local_asms_of thy name_locale |
418 |> map prep_asm |
417 |> map prep_asm |
419 |> tap (fn assms => LOC_AXIOMS := map (fst o fst) assms) |
|
420 end; |
418 end; |
|
419 fun extract_axiom_names thy name_locale = |
|
420 name_locale |
|
421 |> Locale.local_asms_of thy |
|
422 |> map (NameSpace.base o fst o fst) (*FIXME*) |
421 fun mk_const thy class (c, ty) = |
423 fun mk_const thy class (c, ty) = |
422 Const (c, Term.map_type_tfree (fn (v, _) => TFree (v, [class])) ty); |
424 Const (c, Term.map_type_tfree (fn (v, _) => TFree (v, [class])) ty); |
423 in |
425 in |
424 thy |
426 thy |
425 |> add_locale bname supexpr elems |
427 |> add_locale bname supexpr elems |
427 tap (fn thy => check_locale thy name_locale) |
429 tap (fn thy => check_locale thy name_locale) |
428 #> `(fn thy => extract_params thy name_locale) |
430 #> `(fn thy => extract_params thy name_locale) |
429 #-> (fn params => |
431 #-> (fn params => |
430 axclass_params (bname, supsort) params (extract_assumes name_locale params) |
432 axclass_params (bname, supsort) params (extract_assumes name_locale params) |
431 #-> (fn (name_axclass, ((_, ax_axioms), consts)) => |
433 #-> (fn (name_axclass, ((_, ax_axioms), consts)) => |
432 add_class_data ((name_axclass, supclasses), (name_locale, map (fst o fst) params ~~ map fst consts, |
434 `(fn thy => extract_axiom_names thy name_locale) |
433 ! LOC_AXIOMS)) |
435 #-> (fn axiom_names => |
|
436 add_class_data ((name_axclass, supclasses), |
|
437 (name_locale, map (fst o fst) params ~~ map fst consts, axiom_names)) |
434 #> prove_interpretation (Logic.const_of_class bname, []) |
438 #> prove_interpretation (Logic.const_of_class bname, []) |
435 (Locale.Locale name_locale) (map (SOME o mk_const thy name_axclass) (map snd supconsts @ consts)) |
439 (Locale.Locale name_locale) (map (SOME o mk_const thy name_axclass) (map snd supconsts @ consts)) |
436 ((ALLGOALS o ProofContext.fact_tac) ax_axioms) |
440 ((ALLGOALS o ProofContext.fact_tac) ax_axioms) |
437 #> pair name_axclass |
441 #> pair name_axclass |
438 )))) |
442 ))))) |
439 end; |
443 end; |
440 *) |
444 |
441 |
445 (*fun gen_class add_locale prep_class bname raw_supclasses raw_elems thy = |
442 fun gen_class add_locale prep_class bname raw_supclasses raw_elems thy = |
|
443 let |
446 let |
444 val elems = fold_rev (fn Locale.Elem e => cons e | _ => I) raw_elems []; |
447 val elems = fold_rev (fn Locale.Elem e => cons e | _ => I) raw_elems []; |
445 val supclasses = map (prep_class thy) raw_supclasses; |
448 val supclasses = map (prep_class thy) raw_supclasses; |
446 val supsort = |
449 val supsort = |
447 supclasses |
450 supclasses |
513 map (fst o fst) loc_axioms)) |
516 map (fst o fst) loc_axioms)) |
514 #> prove_interpretation (Logic.const_of_class bname, []) |
517 #> prove_interpretation (Logic.const_of_class bname, []) |
515 (Locale.Locale name_locale) (map (SOME o mk_const thy name_axclass) (map snd (mapp_sup @ mapp_this))) |
518 (Locale.Locale name_locale) (map (SOME o mk_const thy name_axclass) (map snd (mapp_sup @ mapp_this))) |
516 ((ALLGOALS o ProofContext.fact_tac) ax_axioms) |
519 ((ALLGOALS o ProofContext.fact_tac) ax_axioms) |
517 ))))) #> pair name_locale) |
520 ))))) #> pair name_locale) |
518 end; |
521 end;*) |
519 |
522 |
520 in |
523 in |
521 |
524 |
522 val class_e = gen_class (Locale.add_locale false) read_class; |
525 val class_e = gen_class (Locale.add_locale false) read_class; |
523 val class = gen_class (Locale.add_locale_i false) certify_class; |
526 val class = gen_class (Locale.add_locale_i false) certify_class; |