72 xstring * Position.T -> typ * Position.report list |
72 xstring * Position.T -> typ * Position.report list |
73 val check_type_name_proper: Proof.context -> bool -> |
73 val check_type_name_proper: Proof.context -> bool -> |
74 xstring * Position.T -> typ * Position.report list |
74 xstring * Position.T -> typ * Position.report list |
75 val read_type_name: Proof.context -> bool -> string -> typ |
75 val read_type_name: Proof.context -> bool -> string -> typ |
76 val read_type_name_proper: Proof.context -> bool -> string -> typ |
76 val read_type_name_proper: Proof.context -> bool -> string -> typ |
|
77 val check_const_proper: Proof.context -> bool -> |
|
78 xstring * Position.T -> term * Position.report list |
77 val read_const_proper: Proof.context -> bool -> string -> term |
79 val read_const_proper: Proof.context -> bool -> string -> term |
78 val read_const: Proof.context -> bool -> typ -> string -> term |
80 val read_const: Proof.context -> bool -> typ -> string -> term |
79 val read_arity: Proof.context -> xstring * string list * string -> arity |
81 val read_arity: Proof.context -> xstring * string list * string -> arity |
80 val cert_arity: Proof.context -> arity -> arity |
82 val cert_arity: Proof.context -> arity -> arity |
81 val allow_dummies: Proof.context -> Proof.context |
83 val allow_dummies: Proof.context -> Proof.context |
82 val prepare_sortsT: Proof.context -> typ list -> string * typ list |
84 val prepare_sortsT: Proof.context -> typ list -> string * typ list |
83 val prepare_sorts: Proof.context -> term list -> string * term list |
85 val prepare_sorts: Proof.context -> term list -> string * term list |
84 val check_tfree: Proof.context -> string * sort -> string * sort |
86 val check_tfree: Proof.context -> string * sort -> string * sort |
85 val intern_skolem: Proof.context -> string -> string option |
|
86 val read_term_pattern: Proof.context -> string -> term |
87 val read_term_pattern: Proof.context -> string -> term |
87 val read_term_schematic: Proof.context -> string -> term |
88 val read_term_schematic: Proof.context -> string -> term |
88 val read_term_abbrev: Proof.context -> string -> term |
89 val read_term_abbrev: Proof.context -> string -> term |
89 val show_abbrevs_raw: Config.raw |
90 val show_abbrevs_raw: Config.raw |
90 val show_abbrevs: bool Config.T |
91 val show_abbrevs: bool Config.T |
472 Syntax.read_token #> Symbol_Pos.source_content #> check_type_name_proper ctxt strict #> #1; |
473 Syntax.read_token #> Symbol_Pos.source_content #> check_type_name_proper ctxt strict #> #1; |
473 |
474 |
474 |
475 |
475 (* constant names *) |
476 (* constant names *) |
476 |
477 |
477 local |
478 fun check_const_proper ctxt strict (c, pos) = |
478 |
|
479 fun prep_const_proper ctxt strict (c, pos) = |
|
480 let |
479 let |
481 fun err msg = error (msg ^ Position.here pos); |
480 fun err msg = error (msg ^ Position.here pos); |
482 val consts = consts_of ctxt; |
481 val consts = consts_of ctxt; |
483 val t as Const (d, _) = |
482 val (t as Const (d, _), reports) = |
484 (case Variable.lookup_const ctxt c of |
483 (case Variable.lookup_const ctxt c of |
485 SOME d => |
484 SOME d => |
486 let |
485 let |
487 val T = Consts.type_scheme (consts_of ctxt) d handle TYPE (msg, _, _) => err msg; |
486 val T = Consts.type_scheme (consts_of ctxt) d handle TYPE (msg, _, _) => err msg; |
488 val _ = Context_Position.report ctxt pos (Name_Space.markup (Consts.space_of consts) d); |
487 val reports = |
489 in Const (d, T) end |
488 if Context_Position.is_reported ctxt pos |
|
489 then [(pos, Name_Space.markup (Consts.space_of consts) d)] else []; |
|
490 in (Const (d, T), reports) end |
490 | NONE => Consts.check_const (Context.Proof ctxt) consts (c, pos)); |
491 | NONE => Consts.check_const (Context.Proof ctxt) consts (c, pos)); |
491 val _ = |
492 val _ = |
492 if strict |
493 if strict |
493 then ignore (Consts.the_const consts d) handle TYPE (msg, _, _) => err msg |
494 then ignore (Consts.the_const consts d) handle TYPE (msg, _, _) => err msg |
494 else (); |
495 else (); |
|
496 in (t, reports) end; |
|
497 |
|
498 fun read_const_proper ctxt strict text = |
|
499 let |
|
500 val (t, reports) = |
|
501 check_const_proper ctxt strict (Symbol_Pos.source_content (Syntax.read_token text)); |
|
502 val _ = Position.reports reports; |
495 in t end; |
503 in t end; |
496 |
|
497 in |
|
498 |
|
499 fun read_const_proper ctxt strict = |
|
500 prep_const_proper ctxt strict o Symbol_Pos.source_content o Syntax.read_token; |
|
501 |
504 |
502 fun read_const ctxt strict ty text = |
505 fun read_const ctxt strict ty text = |
503 let |
506 let |
504 val (c, pos) = Symbol_Pos.source_content (Syntax.read_token text); |
507 val (c, pos) = Symbol_Pos.source_content (Syntax.read_token text); |
505 val _ = Name.reject_internal (c, [pos]); |
508 val _ = Name.reject_internal (c, [pos]); |
506 in |
509 val (t, reports) = |
507 (case (Variable.lookup_fixed ctxt c, Variable.is_const ctxt c) of |
510 (case (Variable.lookup_fixed ctxt c, Variable.is_const ctxt c) of |
508 (SOME x, false) => |
511 (SOME x, false) => |
509 (Context_Position.report ctxt pos |
512 let |
510 (Markup.name x (if Name.is_skolem x then Markup.skolem else Markup.free)); |
513 val reports = |
511 Free (x, infer_type ctxt (x, ty))) |
514 if Context_Position.is_reported ctxt pos |
512 | _ => prep_const_proper ctxt strict (c, pos)) |
515 then [(pos, Markup.name x (if Name.is_skolem x then Markup.skolem else Markup.free))] |
513 end; |
516 else []; |
514 |
517 in (Free (x, infer_type ctxt (x, ty)), reports) end |
515 end; |
518 | _ => check_const_proper ctxt strict (c, pos)); |
|
519 val _ = Position.reports reports; |
|
520 in t end; |
516 |
521 |
517 |
522 |
518 (* type arities *) |
523 (* type arities *) |
519 |
524 |
520 local |
525 local |
529 prep_arity (fn ctxt => #1 o dest_Type o read_type_name_proper ctxt true) Syntax.read_sort; |
534 prep_arity (fn ctxt => #1 o dest_Type o read_type_name_proper ctxt true) Syntax.read_sort; |
530 |
535 |
531 val cert_arity = prep_arity (K I) (Type.cert_sort o tsig_of); |
536 val cert_arity = prep_arity (K I) (Type.cert_sort o tsig_of); |
532 |
537 |
533 end; |
538 end; |
534 |
|
535 |
|
536 (* skolem variables *) |
|
537 |
|
538 fun intern_skolem ctxt x = |
|
539 let |
|
540 val skolem = Variable.lookup_fixed ctxt x; |
|
541 val is_const = can (read_const_proper ctxt false) x orelse Long_Name.is_qualified x; |
|
542 val is_declared = is_some (Variable.def_type ctxt false (x, ~1)); |
|
543 in |
|
544 if Variable.is_const ctxt x then NONE |
|
545 else if is_some skolem then skolem |
|
546 else if not is_const orelse is_declared then SOME x |
|
547 else NONE |
|
548 end; |
|
549 |
539 |
550 |
540 |
551 (* read_term *) |
541 (* read_term *) |
552 |
542 |
553 fun read_term_mode mode ctxt = Syntax.read_term (set_mode mode ctxt); |
543 fun read_term_mode mode ctxt = Syntax.read_term (set_mode mode ctxt); |