63 val read_const_proper: Proof.context -> bool -> string -> term |
63 val read_const_proper: Proof.context -> bool -> string -> term |
64 val read_const: Proof.context -> bool -> typ -> string -> term |
64 val read_const: Proof.context -> bool -> typ -> string -> term |
65 val allow_dummies: Proof.context -> Proof.context |
65 val allow_dummies: Proof.context -> Proof.context |
66 val check_tvar: Proof.context -> indexname * sort -> indexname * sort |
66 val check_tvar: Proof.context -> indexname * sort -> indexname * sort |
67 val check_tfree: Proof.context -> string * sort -> string * sort |
67 val check_tfree: Proof.context -> string * sort -> string * sort |
68 val decode_term: Proof.context -> term -> (Position.T * Markup.T) list * term |
68 val type_context: Proof.context -> Syntax.type_context |
|
69 val term_context: Proof.context -> Syntax.term_context |
|
70 val decode_term: Proof.context -> Position.reports * term -> Position.reports * term |
69 val standard_infer_types: Proof.context -> term list -> term list |
71 val standard_infer_types: Proof.context -> term list -> term list |
70 val read_term_pattern: Proof.context -> string -> term |
72 val read_term_pattern: Proof.context -> string -> term |
71 val read_term_schematic: Proof.context -> string -> term |
73 val read_term_schematic: Proof.context -> string -> term |
72 val read_term_abbrev: Proof.context -> string -> term |
74 val read_term_abbrev: Proof.context -> string -> term |
73 val show_abbrevs_raw: Config.raw |
75 val show_abbrevs_raw: Config.raw |
663 else NONE |
665 else NONE |
664 end; |
666 end; |
665 |
667 |
666 in |
668 in |
667 |
669 |
|
670 fun type_context ctxt : Syntax.type_context = |
|
671 {get_class = read_class ctxt, |
|
672 get_type = #1 o dest_Type o read_type_name_proper ctxt false, |
|
673 markup_class = fn c => [Name_Space.markup_entry (Type.class_space (tsig_of ctxt)) c], |
|
674 markup_type = fn c => [Name_Space.markup_entry (Type.type_space (tsig_of ctxt)) c]}; |
|
675 |
668 fun term_context ctxt : Syntax.term_context = |
676 fun term_context ctxt : Syntax.term_context = |
669 {get_sort = get_sort ctxt, |
677 {get_sort = get_sort ctxt, |
670 get_const = fn a => ((true, #1 (Term.dest_Const (read_const_proper ctxt false a))) |
678 get_const = fn a => ((true, #1 (Term.dest_Const (read_const_proper ctxt false a))) |
671 handle ERROR _ => (false, Consts.intern (consts_of ctxt) a)), |
679 handle ERROR _ => (false, Consts.intern (consts_of ctxt) a)), |
672 get_free = intern_skolem ctxt (Variable.def_type ctxt false), |
680 get_free = intern_skolem ctxt (Variable.def_type ctxt false), |
673 markup_const = fn x => [Name_Space.markup_entry (const_space ctxt) x], |
681 markup_const = fn c => [Name_Space.markup_entry (const_space ctxt) c], |
674 markup_free = fn x => |
682 markup_free = fn x => |
675 [if can Name.dest_skolem x then Markup.skolem else Markup.free] @ |
683 [if can Name.dest_skolem x then Markup.skolem else Markup.free] @ |
676 (if not (Variable.is_body ctxt) orelse Variable.is_fixed ctxt x then [] else [Markup.hilite]), |
684 (if not (Variable.is_body ctxt) orelse Variable.is_fixed ctxt x then [] else [Markup.hilite]), |
677 markup_var = fn xi => [Markup.name (Term.string_of_vname xi) Markup.var]}; |
685 markup_var = fn xi => [Markup.name (Term.string_of_vname xi) Markup.var]}; |
678 |
686 |
746 Markup.markup Markup.report (Context_Position.reported_text ctxt pos Markup.bad "")); |
754 Markup.markup Markup.report (Context_Position.reported_text ctxt pos Markup.bad "")); |
747 |
755 |
748 fun parse_sort ctxt text = |
756 fun parse_sort ctxt text = |
749 let |
757 let |
750 val (syms, pos) = Syntax.parse_token ctxt Markup.sort text; |
758 val (syms, pos) = Syntax.parse_token ctxt Markup.sort text; |
751 val S = Syntax.standard_parse_sort ctxt (syn_of ctxt) (syms, pos) |
759 val S = |
|
760 Syntax.standard_parse_sort ctxt (type_context ctxt) (syn_of ctxt) (syms, pos) |
752 handle ERROR msg => parse_failed ctxt pos msg "sort"; |
761 handle ERROR msg => parse_failed ctxt pos msg "sort"; |
753 in Type.minimize_sort (tsig_of ctxt) S end; |
762 in Type.minimize_sort (tsig_of ctxt) S end; |
754 |
763 |
755 fun parse_typ ctxt text = |
764 fun parse_typ ctxt text = |
756 let |
765 let |
757 val (syms, pos) = Syntax.parse_token ctxt Markup.typ text; |
766 val (syms, pos) = Syntax.parse_token ctxt Markup.typ text; |
758 val T = Syntax.standard_parse_typ ctxt (syn_of ctxt) (get_sort ctxt) (syms, pos) |
767 val T = |
|
768 Syntax.standard_parse_typ ctxt (type_context ctxt) (syn_of ctxt) (get_sort ctxt) (syms, pos) |
759 handle ERROR msg => parse_failed ctxt pos msg "type"; |
769 handle ERROR msg => parse_failed ctxt pos msg "type"; |
760 in T end; |
770 in T end; |
761 |
771 |
762 fun parse_term T ctxt text = |
772 fun parse_term T ctxt text = |
763 let |
773 let |
775 | _ => default_root); |
785 | _ => default_root); |
776 |
786 |
777 fun check t = (Syntax.check_term ctxt (Type.constraint T' t); NONE) |
787 fun check t = (Syntax.check_term ctxt (Type.constraint T' t); NONE) |
778 handle ERROR msg => SOME msg; |
788 handle ERROR msg => SOME msg; |
779 val t = |
789 val t = |
780 Syntax.standard_parse_term check (term_context ctxt) ctxt (syn_of ctxt) root (syms, pos) |
790 Syntax.standard_parse_term check ctxt (type_context ctxt) (term_context ctxt) (syn_of ctxt) |
781 handle ERROR msg => parse_failed ctxt pos msg kind; |
791 root (syms, pos) |
|
792 handle ERROR msg => parse_failed ctxt pos msg kind; |
782 in t end; |
793 in t end; |
783 |
794 |
784 |
795 |
785 fun unparse_sort ctxt = |
796 fun unparse_sort ctxt = |
786 Syntax.standard_unparse_sort {extern_class = Type.extern_class (tsig_of ctxt)} |
797 Syntax.standard_unparse_sort {extern_class = Type.extern_class (tsig_of ctxt)} |
1077 end; |
1088 end; |
1078 |
1089 |
1079 |
1090 |
1080 (* authentic syntax *) |
1091 (* authentic syntax *) |
1081 |
1092 |
1082 val _ = Context.>> |
|
1083 (Context.map_theory |
|
1084 (Sign.add_advanced_trfuns |
|
1085 (Syntax.type_ast_trs |
|
1086 {read_class = read_class, |
|
1087 read_type = fn ctxt => #1 o dest_Type o read_type_name_proper ctxt false}, [], [], []))); |
|
1088 |
|
1089 local |
1093 local |
1090 |
1094 |
1091 fun const_ast_tr intern ctxt [Syntax.Variable c] = |
1095 fun const_ast_tr intern ctxt [Syntax.Variable c] = |
1092 let |
1096 let |
1093 val Const (c', _) = read_const_proper ctxt false c; |
1097 val Const (c', _) = read_const_proper ctxt false c; |