65 string option * (cterm list * cterm list) * context * context * |
65 string option * (cterm list * cterm list) * context * context * |
66 (term * (term list * term list)) list list |
66 (term * (term list * term list)) list list |
67 |
67 |
68 (* Diagnostic functions *) |
68 (* Diagnostic functions *) |
69 val print_locales: theory -> unit |
69 val print_locales: theory -> unit |
70 val print_locale: theory -> expr -> element list -> unit |
70 val print_locale: theory -> bool -> expr -> element list -> unit |
71 val print_global_registrations: bool -> string -> theory -> unit |
71 val print_global_registrations: bool -> string -> theory -> unit |
72 val print_local_registrations': bool -> string -> context -> unit |
72 val print_local_registrations': bool -> string -> context -> unit |
73 val print_local_registrations: bool -> string -> context -> unit |
73 val print_local_registrations: bool -> string -> context -> unit |
74 |
74 |
75 (* Storing results *) |
75 (* Storing results *) |
1618 |
1618 |
1619 (** define locales **) |
1619 (** define locales **) |
1620 |
1620 |
1621 (* print locale *) |
1621 (* print locale *) |
1622 |
1622 |
1623 fun print_locale thy import body = |
1623 fun print_locale thy show_facts import body = |
1624 let |
1624 let |
1625 val thy_ctxt = ProofContext.init thy; |
1625 val thy_ctxt = ProofContext.init thy; |
1626 val (((_, import_elemss), (ctxt, elemss, _)), _) = read_context import body thy_ctxt; |
1626 val (((_, import_elemss), (ctxt, elemss, _)), _) = read_context import body thy_ctxt; |
1627 val all_elems = List.concat (map #2 (import_elemss @ elemss)); |
1627 val all_elems = List.concat (map #2 (import_elemss @ elemss)); |
1628 |
1628 |
1659 | items prfx (x :: xs) = Pretty.block [Pretty.str prfx, Pretty.brk 1, x] :: items " and" xs; |
1659 | items prfx (x :: xs) = Pretty.block [Pretty.str prfx, Pretty.brk 1, x] :: items " and" xs; |
1660 fun prt_elem (Fixes fixes) = items "fixes" (map prt_fix fixes) |
1660 fun prt_elem (Fixes fixes) = items "fixes" (map prt_fix fixes) |
1661 | prt_elem (Constrains csts) = items "constrains" (map prt_cst csts) |
1661 | prt_elem (Constrains csts) = items "constrains" (map prt_cst csts) |
1662 | prt_elem (Assumes asms) = items "assumes" (map prt_asm asms) |
1662 | prt_elem (Assumes asms) = items "assumes" (map prt_asm asms) |
1663 | prt_elem (Defines defs) = items "defines" (map prt_def defs) |
1663 | prt_elem (Defines defs) = items "defines" (map prt_def defs) |
1664 | prt_elem (Notes facts) = items "notes" (map prt_note facts); |
1664 | prt_elem (Notes facts) = |
|
1665 if show_facts then items "notes" (map prt_note facts) else []; |
1665 in |
1666 in |
1666 Pretty.big_list "context elements:" (map (Pretty.chunks o prt_elem) all_elems) |
1667 Pretty.big_list "context elements:" (map (Pretty.chunks o prt_elem) all_elems) |
1667 |> Pretty.writeln |
1668 |> Pretty.writeln |
1668 end; |
1669 end; |
1669 |
1670 |
1972 val name = Sign.full_name thy bname; |
1973 val name = Sign.full_name thy bname; |
1973 val _ = conditional (isSome (get_locale thy name)) (fn () => |
1974 val _ = conditional (isSome (get_locale thy name)) (fn () => |
1974 error ("Duplicate definition of locale " ^ quote name)); |
1975 error ("Duplicate definition of locale " ^ quote name)); |
1975 |
1976 |
1976 val thy_ctxt = ProofContext.init thy; |
1977 val thy_ctxt = ProofContext.init thy; |
1977 val (((import_ctxt, import_elemss), (body_ctxt, body_elemss, syn)), text) = |
1978 val (((import_ctxt, import_elemss), (body_ctxt, body_elemss, syn)), |
|
1979 text as (parms, ((_, exts'), _), _)) = |
1978 prep_ctxt raw_import raw_body thy_ctxt; |
1980 prep_ctxt raw_import raw_body thy_ctxt; |
1979 val elemss = import_elemss @ body_elemss; |
1981 val elemss = import_elemss @ body_elemss; |
1980 val import = prep_expr thy raw_import; |
1982 val import = prep_expr thy raw_import; |
|
1983 |
|
1984 val extraTs = foldr Term.add_term_tfrees [] exts' \\ |
|
1985 foldr Term.add_typ_tfrees [] (map #2 parms); |
|
1986 val _ = if null extraTs then () |
|
1987 else warning ("Encountered type variables in specification text that don't occur in the\n" ^ "locale parameters."); |
1981 |
1988 |
1982 val (pred_thy, (elemss', predicate as (predicate_statement, predicate_axioms))) = |
1989 val (pred_thy, (elemss', predicate as (predicate_statement, predicate_axioms))) = |
1983 if do_pred then thy |> define_preds bname text elemss |
1990 if do_pred then thy |> define_preds bname text elemss |
1984 else (thy, (elemss, ([], []))); |
1991 else (thy, (elemss, ([], []))); |
1985 val pred_ctxt = ProofContext.init pred_thy; |
1992 val pred_ctxt = ProofContext.init pred_thy; |