equal
deleted
inserted
replaced
420 val cert_typ_syntax = cert_typ_mode Type.mode_syntax; |
420 val cert_typ_syntax = cert_typ_mode Type.mode_syntax; |
421 val cert_typ_abbrev = cert_typ_mode Type.mode_abbrev; |
421 val cert_typ_abbrev = cert_typ_mode Type.mode_abbrev; |
422 |
422 |
423 |
423 |
424 |
424 |
425 (** prepare variables **) |
|
426 |
|
427 (* check Skolem constants *) |
|
428 |
|
429 fun no_skolem internal x = |
|
430 if Name.is_skolem x then |
|
431 error ("Illegal reference to internal Skolem constant: " ^ quote x) |
|
432 else if not internal andalso Name.is_internal x then |
|
433 error ("Illegal reference to internal variable: " ^ quote x) |
|
434 else x; |
|
435 |
|
436 |
|
437 |
|
438 (** prepare terms and propositions **) |
425 (** prepare terms and propositions **) |
439 |
426 |
440 (* inferred types of parameters *) |
427 (* inferred types of parameters *) |
441 |
428 |
442 fun infer_type ctxt x = |
429 fun infer_type ctxt x = |
513 prep_const_proper ctxt strict o Symbol_Pos.source_content o Syntax.read_token; |
500 prep_const_proper ctxt strict o Symbol_Pos.source_content o Syntax.read_token; |
514 |
501 |
515 fun read_const ctxt strict ty text = |
502 fun read_const ctxt strict ty text = |
516 let |
503 let |
517 val (c, pos) = Symbol_Pos.source_content (Syntax.read_token text); |
504 val (c, pos) = Symbol_Pos.source_content (Syntax.read_token text); |
518 val _ = no_skolem false c; |
505 val _ = Name.reject_internal (c, [pos]); |
519 in |
506 in |
520 (case (Variable.lookup_fixed ctxt c, Variable.is_const ctxt c) of |
507 (case (Variable.lookup_fixed ctxt c, Variable.is_const ctxt c) of |
521 (SOME x, false) => |
508 (SOME x, false) => |
522 (Context_Position.report ctxt pos |
509 (Context_Position.report ctxt pos |
523 (Markup.name x (if Name.is_skolem x then Markup.skolem else Markup.free)); |
510 (Markup.name x (if Name.is_skolem x then Markup.skolem else Markup.free)); |
548 |
535 |
549 (* skolem variables *) |
536 (* skolem variables *) |
550 |
537 |
551 fun intern_skolem ctxt x = |
538 fun intern_skolem ctxt x = |
552 let |
539 let |
553 val _ = no_skolem false x; |
540 val skolem = Variable.lookup_fixed ctxt x; |
554 val sko = Variable.lookup_fixed ctxt x; |
|
555 val is_const = can (read_const_proper ctxt false) x orelse Long_Name.is_qualified x; |
541 val is_const = can (read_const_proper ctxt false) x orelse Long_Name.is_qualified x; |
556 val is_declared = is_some (Variable.def_type ctxt false (x, ~1)); |
542 val is_declared = is_some (Variable.def_type ctxt false (x, ~1)); |
557 in |
543 in |
558 if Variable.is_const ctxt x then NONE |
544 if Variable.is_const ctxt x then NONE |
559 else if is_some sko then sko |
545 else if is_some skolem then skolem |
560 else if not is_const orelse is_declared then SOME x |
546 else if not is_const orelse is_declared then SOME x |
561 else NONE |
547 else NONE |
562 end; |
548 end; |
563 |
549 |
564 |
550 |
1031 |
1017 |
1032 fun prep_vars prep_typ internal = |
1018 fun prep_vars prep_typ internal = |
1033 fold_map (fn (b, raw_T, mx) => fn ctxt => |
1019 fold_map (fn (b, raw_T, mx) => fn ctxt => |
1034 let |
1020 let |
1035 val x = Variable.check_name b; |
1021 val x = Variable.check_name b; |
1036 val _ = Symbol_Pos.is_identifier (no_skolem internal x) orelse |
1022 val check_name = if internal then Name.reject_skolem else Name.reject_internal; |
1037 error ("Illegal variable name: " ^ Binding.print b); |
1023 val _ = |
|
1024 if can check_name (x, []) andalso Symbol_Pos.is_identifier x then () |
|
1025 else error ("Bad name: " ^ Binding.print b); |
1038 |
1026 |
1039 fun cond_tvars T = |
1027 fun cond_tvars T = |
1040 if internal then T |
1028 if internal then T |
1041 else Type.no_tvars T handle TYPE (msg, _, _) => error msg; |
1029 else Type.no_tvars T handle TYPE (msg, _, _) => error msg; |
1042 val opt_T = Option.map (cond_tvars o cert_typ ctxt o prep_typ ctxt) raw_T; |
1030 val opt_T = Option.map (cond_tvars o cert_typ ctxt o prep_typ ctxt) raw_T; |