45 val nodup_vars: term -> term |
45 val nodup_vars: term -> term |
46 val norm_sort: sg -> sort -> sort |
46 val norm_sort: sg -> sort -> sort |
47 val of_sort: sg -> typ * sort -> bool |
47 val of_sort: sg -> typ * sort -> bool |
48 val witness_sorts: sg -> sort list -> sort list -> (typ * sort) list |
48 val witness_sorts: sg -> sort list -> sort list -> (typ * sort) list |
49 val univ_witness: sg -> (typ * sort) option |
49 val univ_witness: sg -> (typ * sort) option |
50 val is_type_abbr: sg -> string -> bool |
|
51 val classK: string |
50 val classK: string |
52 val typeK: string |
51 val typeK: string |
53 val constK: string |
52 val constK: string |
54 val full_name: sg -> bstring -> string |
53 val full_name: sg -> bstring -> string |
55 val full_name_path: sg -> string -> bstring -> string |
54 val full_name_path: sg -> string -> bstring -> string |
79 val str_of_sort: sg -> sort -> string |
78 val str_of_sort: sg -> sort -> string |
80 val str_of_classrel: sg -> class * class -> string |
79 val str_of_classrel: sg -> class * class -> string |
81 val str_of_arity: sg -> string * sort list * sort -> string |
80 val str_of_arity: sg -> string * sort list * sort -> string |
82 val pprint_term: sg -> term -> pprint_args -> unit |
81 val pprint_term: sg -> term -> pprint_args -> unit |
83 val pprint_typ: sg -> typ -> pprint_args -> unit |
82 val pprint_typ: sg -> typ -> pprint_args -> unit |
|
83 val certify_class: sg -> class -> class |
|
84 val certify_sort: sg -> sort -> sort |
84 val certify_typ: sg -> typ -> typ |
85 val certify_typ: sg -> typ -> typ |
85 val certify_term: sg -> term -> term * typ * int |
86 val certify_term: sg -> term -> term * typ * int |
|
87 val read_sort: sg -> string -> sort |
86 val read_raw_typ: sg * (indexname -> sort option) -> string -> typ |
88 val read_raw_typ: sg * (indexname -> sort option) -> string -> typ |
87 val read_typ: sg * (indexname -> sort option) -> string -> typ |
89 val read_typ: sg * (indexname -> sort option) -> string -> typ |
88 val infer_types: sg -> (indexname -> typ option) -> |
90 val infer_types: sg -> (indexname -> typ option) -> |
89 (indexname -> sort option) -> string list -> bool |
91 (indexname -> sort option) -> string list -> bool |
90 -> xterm list * typ -> term * (indexname * typ) list |
92 -> xterm list * typ -> term * (indexname * typ) list |
97 val simple_read_term: sg -> typ -> string -> term |
99 val simple_read_term: sg -> typ -> string -> term |
98 val add_classes: (bclass * xclass list) list -> sg -> sg |
100 val add_classes: (bclass * xclass list) list -> sg -> sg |
99 val add_classes_i: (bclass * class list) list -> sg -> sg |
101 val add_classes_i: (bclass * class list) list -> sg -> sg |
100 val add_classrel: (xclass * xclass) list -> sg -> sg |
102 val add_classrel: (xclass * xclass) list -> sg -> sg |
101 val add_classrel_i: (class * class) list -> sg -> sg |
103 val add_classrel_i: (class * class) list -> sg -> sg |
102 val add_defsort: xsort -> sg -> sg |
104 val add_defsort: string -> sg -> sg |
103 val add_defsort_i: sort -> sg -> sg |
105 val add_defsort_i: sort -> sg -> sg |
104 val add_types: (bstring * int * mixfix) list -> sg -> sg |
106 val add_types: (bstring * int * mixfix) list -> sg -> sg |
105 val add_nonterminals: bstring list -> sg -> sg |
107 val add_nonterminals: bstring list -> sg -> sg |
106 val add_tyabbrs: (bstring * string list * string * mixfix) list -> sg -> sg |
108 val add_tyabbrs: (bstring * string list * string * mixfix) list -> sg -> sg |
107 val add_tyabbrs_i: (bstring * string list * typ * mixfix) list -> sg -> sg |
109 val add_tyabbrs_i: (bstring * string list * typ * mixfix) list -> sg -> sg |
108 val add_arities: (xstring * xsort list * xsort) list -> sg -> sg |
110 val add_arities: (xstring * string list * string) list -> sg -> sg |
109 val add_arities_i: (string * sort list * sort) list -> sg -> sg |
111 val add_arities_i: (string * sort list * sort) list -> sg -> sg |
110 val add_consts: (bstring * string * mixfix) list -> sg -> sg |
112 val add_consts: (bstring * string * mixfix) list -> sg -> sg |
111 val add_consts_i: (bstring * typ * mixfix) list -> sg -> sg |
113 val add_consts_i: (bstring * typ * mixfix) list -> sg -> sg |
112 val add_syntax: (bstring * string * mixfix) list -> sg -> sg |
114 val add_syntax: (bstring * string * mixfix) list -> sg -> sg |
113 val add_syntax_i: (bstring * typ * mixfix) list -> sg -> sg |
115 val add_syntax_i: (bstring * typ * mixfix) list -> sg -> sg |
269 val subsort = Type.subsort o tsig_of; |
271 val subsort = Type.subsort o tsig_of; |
270 val norm_sort = Type.norm_sort o tsig_of; |
272 val norm_sort = Type.norm_sort o tsig_of; |
271 val of_sort = Type.of_sort o tsig_of; |
273 val of_sort = Type.of_sort o tsig_of; |
272 val witness_sorts = Type.witness_sorts o tsig_of; |
274 val witness_sorts = Type.witness_sorts o tsig_of; |
273 val univ_witness = Type.univ_witness o tsig_of; |
275 val univ_witness = Type.univ_witness o tsig_of; |
274 val is_type_abbr = Type.is_type_abbr o tsig_of; |
|
275 |
276 |
276 |
277 |
277 |
278 |
278 (** signature data **) |
279 (** signature data **) |
279 |
280 |
539 fun pprint_term sg = Pretty.pprint o Pretty.quote o (pretty_term sg); |
540 fun pprint_term sg = Pretty.pprint o Pretty.quote o (pretty_term sg); |
540 fun pprint_typ sg = Pretty.pprint o Pretty.quote o (pretty_typ sg); |
541 fun pprint_typ sg = Pretty.pprint o Pretty.quote o (pretty_typ sg); |
541 |
542 |
542 |
543 |
543 |
544 |
|
545 (** read sorts **) (*exception ERROR*) |
|
546 |
|
547 fun err_in_sort s = |
|
548 error ("The error(s) above occurred in sort " ^ quote s); |
|
549 |
|
550 fun rd_sort syn tsig spaces str = |
|
551 let val S = intrn_sort spaces (Syntax.read_sort syn str handle ERROR => err_in_sort str) |
|
552 in Type.cert_sort tsig S handle TYPE (msg, _, _) => (error_msg msg; err_in_sort str) end; |
|
553 |
|
554 (*read and certify sort wrt a signature*) |
|
555 fun read_sort (sg as Sg (_, {tsig, syn, spaces, ...})) str = |
|
556 (check_stale sg; rd_sort syn tsig spaces str); |
|
557 |
|
558 fun cert_sort _ tsig _ = Type.cert_sort tsig; |
|
559 |
|
560 |
|
561 |
544 (** read types **) (*exception ERROR*) |
562 (** read types **) (*exception ERROR*) |
545 |
563 |
546 fun err_in_type s = |
564 fun err_in_type s = |
547 error ("The error(s) above occurred in type " ^ quote s); |
565 error ("The error(s) above occurred in type " ^ quote s); |
548 |
566 |
559 (Type.cert_typ (tsig_of sg) (read_raw_typ (sg, def_sort) str) |
577 (Type.cert_typ (tsig_of sg) (read_raw_typ (sg, def_sort) str) |
560 handle TYPE (msg, _, _) => (error_msg msg; err_in_type str)); |
578 handle TYPE (msg, _, _) => (error_msg msg; err_in_type str)); |
561 |
579 |
562 |
580 |
563 |
581 |
564 (** certify types and terms **) (*exception TYPE*) |
582 (** certify classes, sorts, types and terms **) (*exception TYPE*) |
565 |
583 |
566 (* certify_typ *) |
584 val certify_class = Type.cert_class o tsig_of; |
567 |
585 val certify_sort = Type.cert_sort o tsig_of; |
568 val certify_typ = Type.cert_typ o tsig_of; |
586 val certify_typ = Type.cert_typ o tsig_of; |
569 |
587 |
570 |
588 |
571 (* certify_term *) |
589 (* certify_term *) |
572 |
590 |
758 fun no_read _ _ _ decl = decl; |
776 fun no_read _ _ _ decl = decl; |
759 |
777 |
760 |
778 |
761 (* add default sort *) |
779 (* add default sort *) |
762 |
780 |
763 fun ext_defsort int (syn, tsig, ctab, (path, spaces), data) S = |
781 fun ext_defS prep_sort (syn, tsig, ctab, (path, spaces), data) S = |
764 (syn, Type.ext_tsig_defsort tsig (if int then intrn_sort spaces S else S), |
782 (syn, Type.ext_tsig_defsort tsig (prep_sort syn tsig spaces S), ctab, (path, spaces), data); |
765 ctab, (path, spaces), data); |
783 |
|
784 val ext_defsort = ext_defS rd_sort; |
|
785 val ext_defsort_i = ext_defS cert_sort; |
766 |
786 |
767 |
787 |
768 (* add type constructors *) |
788 (* add type constructors *) |
769 |
789 |
770 fun ext_types (syn, tsig, ctab, (path, spaces), data) types = |
790 fun ext_types (syn, tsig, ctab, (path, spaces), data) types = |
802 fun ext_tyabbrs_i abbrs = ext_abbrs no_read abbrs; |
822 fun ext_tyabbrs_i abbrs = ext_abbrs no_read abbrs; |
803 |
823 |
804 |
824 |
805 (* add type arities *) |
825 (* add type arities *) |
806 |
826 |
807 fun ext_arities int (syn, tsig, ctab, (path, spaces), data) arities = |
827 fun ext_ars int prep_sort (syn, tsig, ctab, (path, spaces), data) arities = |
808 let |
828 let |
809 fun intrn_arity (c, Ss, S) = |
829 val prepS = prep_sort syn tsig spaces; |
810 (intrn spaces typeK c, map (intrn_sort spaces) Ss, intrn_sort spaces S); |
830 fun prep_arity (c, Ss, S) = |
811 val intrn = if int then map intrn_arity else I; |
831 (if int then intrn spaces typeK c else c, map prepS Ss, prepS S); |
812 val tsig' = Type.ext_tsig_arities tsig (intrn arities); |
832 val tsig' = Type.ext_tsig_arities tsig (map prep_arity arities); |
813 val log_types = Type.logical_types tsig'; |
833 val log_types = Type.logical_types tsig'; |
814 in |
834 in |
815 (Syntax.extend_log_types syn log_types, tsig', ctab, (path, spaces), data) |
835 (Syntax.extend_log_types syn log_types, tsig', ctab, (path, spaces), data) |
816 end; |
836 end; |
|
837 |
|
838 val ext_arities = ext_ars true rd_sort; |
|
839 val ext_arities_i = ext_ars false cert_sort; |
817 |
840 |
818 |
841 |
819 (* add term constants and syntax *) |
842 (* add term constants and syntax *) |
820 |
843 |
821 fun const_name path c mx = |
844 fun const_name path c mx = |
962 |
985 |
963 val add_classes = extend_sign true (ext_classes true) "#"; |
986 val add_classes = extend_sign true (ext_classes true) "#"; |
964 val add_classes_i = extend_sign true (ext_classes false) "#"; |
987 val add_classes_i = extend_sign true (ext_classes false) "#"; |
965 val add_classrel = extend_sign true (ext_classrel true) "#"; |
988 val add_classrel = extend_sign true (ext_classrel true) "#"; |
966 val add_classrel_i = extend_sign true (ext_classrel false) "#"; |
989 val add_classrel_i = extend_sign true (ext_classrel false) "#"; |
967 val add_defsort = extend_sign true (ext_defsort true) "#"; |
990 val add_defsort = extend_sign true ext_defsort "#"; |
968 val add_defsort_i = extend_sign true (ext_defsort false) "#"; |
991 val add_defsort_i = extend_sign true ext_defsort_i "#"; |
969 val add_types = extend_sign true ext_types "#"; |
992 val add_types = extend_sign true ext_types "#"; |
970 val add_nonterminals = extend_sign true ext_nonterminals "#"; |
993 val add_nonterminals = extend_sign true ext_nonterminals "#"; |
971 val add_tyabbrs = extend_sign true ext_tyabbrs "#"; |
994 val add_tyabbrs = extend_sign true ext_tyabbrs "#"; |
972 val add_tyabbrs_i = extend_sign true ext_tyabbrs_i "#"; |
995 val add_tyabbrs_i = extend_sign true ext_tyabbrs_i "#"; |
973 val add_arities = extend_sign true (ext_arities true) "#"; |
996 val add_arities = extend_sign true ext_arities "#"; |
974 val add_arities_i = extend_sign true (ext_arities false) "#"; |
997 val add_arities_i = extend_sign true ext_arities_i "#"; |
975 val add_consts = extend_sign true ext_consts "#"; |
998 val add_consts = extend_sign true ext_consts "#"; |
976 val add_consts_i = extend_sign true ext_consts_i "#"; |
999 val add_consts_i = extend_sign true ext_consts_i "#"; |
977 val add_syntax = extend_sign true ext_syntax "#"; |
1000 val add_syntax = extend_sign true ext_syntax "#"; |
978 val add_syntax_i = extend_sign true ext_syntax_i "#"; |
1001 val add_syntax_i = extend_sign true ext_syntax_i "#"; |
979 val add_modesyntax = extend_sign true ext_modesyntax "#"; |
1002 val add_modesyntax = extend_sign true ext_modesyntax "#"; |