79 val map_terms_bottom_up: (iterm -> iterm) -> iterm -> iterm |
79 val map_terms_bottom_up: (iterm -> iterm) -> iterm -> iterm |
80 val map_terms_stmt: (iterm -> iterm) -> stmt -> stmt |
80 val map_terms_stmt: (iterm -> iterm) -> stmt -> stmt |
81 val is_cons: program -> string -> bool |
81 val is_cons: program -> string -> bool |
82 val contr_classparam_typs: program -> string -> itype option list |
82 val contr_classparam_typs: program -> string -> itype option list |
83 |
83 |
|
84 val read_const_exprs: theory -> string list -> string list * string list |
84 val consts_program: theory -> string list -> string list * (naming * program) |
85 val consts_program: theory -> string list -> string list * (naming * program) |
85 val cached_program: theory -> naming * program |
86 val cached_program: theory -> naming * program |
86 val eval_conv: theory -> (sort -> sort) |
87 val eval_conv: theory -> (sort -> sort) |
87 -> (naming -> program -> (((string * sort) list * typscheme) * (string * itype) list) * iterm -> string list -> cterm -> thm) |
88 -> (naming -> program -> (((string * sort) list * typscheme) * (string * itype) list) * iterm -> string list -> cterm -> thm) |
88 -> cterm -> thm |
89 -> cterm -> thm |
237 fun thyname_of_const thy c = case AxClass.class_of_param thy c |
238 fun thyname_of_const thy c = case AxClass.class_of_param thy c |
238 of SOME class => thyname_of_class thy class |
239 of SOME class => thyname_of_class thy class |
239 | NONE => (case Code.get_datatype_of_constr thy c |
240 | NONE => (case Code.get_datatype_of_constr thy c |
240 of SOME dtco => thyname_of_tyco thy dtco |
241 of SOME dtco => thyname_of_tyco thy dtco |
241 | NONE => thyname_of thy (Consts.the_tags (Sign.consts_of thy)) c); |
242 | NONE => thyname_of thy (Consts.the_tags (Sign.consts_of thy)) c); |
|
243 fun purify_base "op &" = "and" |
|
244 | purify_base "op |" = "or" |
|
245 | purify_base "op -->" = "implies" |
|
246 | purify_base "op :" = "member" |
|
247 | purify_base "op =" = "eq" |
|
248 | purify_base "*" = "product" |
|
249 | purify_base "+" = "sum" |
|
250 | purify_base s = Name.desymbolize false s; |
242 fun namify thy get_basename get_thyname name = |
251 fun namify thy get_basename get_thyname name = |
243 let |
252 let |
244 val prefix = get_thyname thy name; |
253 val prefix = get_thyname thy name; |
245 val base = (Code_Name.purify_base o get_basename) name; |
254 val base = (purify_base o get_basename) name; |
246 in Long_Name.append prefix base end; |
255 in Long_Name.append prefix base end; |
247 in |
256 in |
248 |
257 |
249 fun namify_class thy = namify thy Long_Name.base_name thyname_of_class; |
258 fun namify_class thy = namify thy Long_Name.base_name thyname_of_class; |
250 fun namify_classrel thy = namify thy (fn (class1, class2) => |
259 fun namify_classrel thy = namify thy (fn (class1, class2) => |
780 fun eval thy prep_sort postproc = Code_Wellsorted.eval thy prep_sort postproc o base_evaluator thy; |
789 fun eval thy prep_sort postproc = Code_Wellsorted.eval thy prep_sort postproc o base_evaluator thy; |
781 |
790 |
782 |
791 |
783 (** diagnostic commands **) |
792 (** diagnostic commands **) |
784 |
793 |
|
794 fun read_const_exprs thy = |
|
795 let |
|
796 fun consts_of some_thyname = |
|
797 let |
|
798 val thy' = case some_thyname |
|
799 of SOME thyname => ThyInfo.the_theory thyname thy |
|
800 | NONE => thy; |
|
801 val cs = Symtab.fold (fn (c, (_, NONE)) => cons c | _ => I) |
|
802 ((snd o #constants o Consts.dest o #consts o Sign.rep_sg) thy') []; |
|
803 fun belongs_here c = |
|
804 not (exists (fn thy'' => Sign.declared_const thy'' c) (Theory.parents_of thy')) |
|
805 in case some_thyname |
|
806 of NONE => cs |
|
807 | SOME thyname => filter belongs_here cs |
|
808 end; |
|
809 fun read_const_expr "*" = ([], consts_of NONE) |
|
810 | read_const_expr s = if String.isSuffix ".*" s |
|
811 then ([], consts_of (SOME (unsuffix ".*" s))) |
|
812 else ([Code_Unit.read_const thy s], []); |
|
813 in pairself flat o split_list o map read_const_expr end; |
|
814 |
785 fun code_depgr thy consts = |
815 fun code_depgr thy consts = |
786 let |
816 let |
787 val (_, eqngr) = Code_Wellsorted.obtain thy consts []; |
817 val (_, eqngr) = Code_Wellsorted.obtain thy consts []; |
788 val select = Graph.all_succs eqngr consts; |
818 val select = Graph.all_succs eqngr consts; |
789 in |
819 in |