175 val read_typ_syntax: theory * (indexname -> sort option) -> string -> typ |
175 val read_typ_syntax: theory * (indexname -> sort option) -> string -> typ |
176 val read_typ_abbrev: theory * (indexname -> sort option) -> string -> typ |
176 val read_typ_abbrev: theory * (indexname -> sort option) -> string -> typ |
177 val read_tyname: theory -> string -> typ |
177 val read_tyname: theory -> string -> typ |
178 val read_const: theory -> string -> term |
178 val read_const: theory -> string -> term |
179 val infer_types_simult: Pretty.pp -> theory -> Consts.T -> (indexname -> typ option) -> |
179 val infer_types_simult: Pretty.pp -> theory -> Consts.T -> (indexname -> typ option) -> |
180 (indexname -> sort option) -> string list -> bool |
180 (indexname -> sort option) -> Name.context -> bool |
181 -> (term list * typ) list -> term list * (indexname * typ) list |
181 -> (term list * typ) list -> term list * (indexname * typ) list |
182 val infer_types: Pretty.pp -> theory -> Consts.T -> (indexname -> typ option) -> |
182 val infer_types: Pretty.pp -> theory -> Consts.T -> (indexname -> typ option) -> |
183 (indexname -> sort option) -> string list -> bool |
183 (indexname -> sort option) -> Name.context -> bool |
184 -> term list * typ -> term * (indexname * typ) list |
184 -> term list * typ -> term * (indexname * typ) list |
185 val read_def_terms': Pretty.pp -> (string -> bool) -> Syntax.syntax -> Consts.T -> |
185 val read_def_terms': Pretty.pp -> (string -> bool) -> Syntax.syntax -> Consts.T -> |
186 Context.generic -> (indexname -> typ option) * (indexname -> sort option) -> |
186 Context.generic -> (indexname -> typ option) * (indexname -> sort option) -> |
187 string list -> bool -> (string * typ) list -> term list * (indexname * typ) list |
187 Name.context -> bool -> (string * typ) list -> term list * (indexname * typ) list |
188 val read_def_terms: |
188 val read_def_terms: |
189 theory * (indexname -> typ option) * (indexname -> sort option) -> |
189 theory * (indexname -> typ option) * (indexname -> sort option) -> |
190 string list -> bool -> (string * typ) list -> term list * (indexname * typ) list |
190 string list -> bool -> (string * typ) list -> term list * (indexname * typ) list |
191 val simple_read_term: theory -> typ -> string -> term |
191 val simple_read_term: theory -> typ -> string -> term |
192 val read_term: theory -> string -> term |
192 val read_term: theory -> string -> term |
572 (** infer_types **) (*exception ERROR*) |
572 (** infer_types **) (*exception ERROR*) |
573 |
573 |
574 (* |
574 (* |
575 def_type: partial map from indexnames to types (constrains Frees and Vars) |
575 def_type: partial map from indexnames to types (constrains Frees and Vars) |
576 def_sort: partial map from indexnames to sorts (constrains TFrees and TVars) |
576 def_sort: partial map from indexnames to sorts (constrains TFrees and TVars) |
577 used: list of already used type variables |
577 used: context of already used type variables |
578 freeze: if true then generated parameters are turned into TFrees, else TVars |
578 freeze: if true then generated parameters are turned into TFrees, else TVars |
579 |
579 |
580 termss: lists of alternative parses (only one combination should be type-correct) |
580 termss: lists of alternative parses (only one combination should be type-correct) |
581 typs: expected types |
581 typs: expected types |
582 *) |
582 *) |
625 fun read (s, T) = |
625 fun read (s, T) = |
626 let val T' = certify_typ thy T handle TYPE (msg, _, _) => error msg |
626 let val T' = certify_typ thy T handle TYPE (msg, _, _) => error msg |
627 in (Syntax.read context is_logtype syn T' s, T') end; |
627 in (Syntax.read context is_logtype syn T' s, T') end; |
628 in infer_types_simult pp thy consts types sorts used freeze (map read sTs) end; |
628 in infer_types_simult pp thy consts types sorts used freeze (map read sTs) end; |
629 |
629 |
630 fun read_def_terms (thy, types, sorts) = |
630 fun read_def_terms (thy, types, sorts) used = |
631 read_def_terms' (pp thy) (is_logtype thy) (syn_of thy) (consts_of thy) |
631 read_def_terms' (pp thy) (is_logtype thy) (syn_of thy) (consts_of thy) |
632 (Context.Theory thy) (types, sorts); |
632 (Context.Theory thy) (types, sorts) (Name.make_context used); |
633 |
633 |
634 fun simple_read_term thy T s = |
634 fun simple_read_term thy T s = |
635 let val ([t], _) = read_def_terms (thy, K NONE, K NONE) [] true [(s, T)] |
635 let val ([t], _) = read_def_terms (thy, K NONE, K NONE) [] true [(s, T)] |
636 in t end |
636 in t end |
637 handle ERROR msg => cat_error msg ("The error(s) above occurred for term " ^ s); |
637 handle ERROR msg => cat_error msg ("The error(s) above occurred for term " ^ s); |