386 (* internalize Skolem constants *) |
386 (* internalize Skolem constants *) |
387 |
387 |
388 fun fixes_of (Context {asms = (_, (fixes, _)), ...}) = fixes; |
388 fun fixes_of (Context {asms = (_, (fixes, _)), ...}) = fixes; |
389 fun get_skolem ctxt x = assoc (fixes_of ctxt, x); |
389 fun get_skolem ctxt x = assoc (fixes_of ctxt, x); |
390 |
390 |
391 fun no_internal_skolem ctxt x = |
391 fun no_skolem no_internal ctxt x = |
392 if can Syntax.dest_skolem x then |
392 if can Syntax.dest_skolem x then |
393 raise CONTEXT ("Illegal reference to internal Skolem constant: " ^ quote x, ctxt) |
393 raise CONTEXT ("Illegal reference to internal Skolem constant: " ^ quote x, ctxt) |
394 else if can Syntax.dest_internal x then |
394 else if no_internal andalso can Syntax.dest_internal x then |
395 raise CONTEXT ("Illegal reference to internal variable: " ^ quote x, ctxt) |
395 raise CONTEXT ("Illegal reference to internal variable: " ^ quote x, ctxt) |
396 else x; |
396 else x; |
397 |
397 |
398 fun intern_skolem ctxt = |
398 fun intern_skolem ctxt = |
399 let |
399 let |
400 fun intern (t as Free (x, T)) = |
400 fun intern (t as Free (x, T)) = |
401 (case get_skolem ctxt (no_internal_skolem ctxt x) of |
401 (case get_skolem ctxt (no_skolem true ctxt x) of |
402 Some x' => Free (x', T) |
402 Some x' => Free (x', T) |
403 | None => t) |
403 | None => t) |
404 | intern (t $ u) = intern t $ intern u |
404 | intern (t $ u) = intern t $ intern u |
405 | intern (Abs (x, T, t)) = Abs (x, T, intern t) |
405 | intern (Abs (x, T, t)) = Abs (x, T, intern t) |
406 | intern a = a; |
406 | intern a = a; |
915 |
915 |
916 (* variables *) |
916 (* variables *) |
917 |
917 |
918 fun prep_vars prep_typ (ctxt, (xs, raw_T)) = |
918 fun prep_vars prep_typ (ctxt, (xs, raw_T)) = |
919 let |
919 let |
920 val _ = (case filter (not o Syntax.is_identifier) (map (no_internal_skolem ctxt) xs) of |
920 val _ = (case filter (not o Syntax.is_identifier) (map (no_skolem false ctxt) xs) of |
921 [] => () | bads => raise CONTEXT ("Bad variable name(s): " ^ commas_quote bads, ctxt)); |
921 [] => () | bads => raise CONTEXT ("Bad variable name(s): " ^ commas_quote bads, ctxt)); |
922 |
922 |
923 val opt_T = apsome (prep_typ ctxt) raw_T; |
923 val opt_T = apsome (prep_typ ctxt) raw_T; |
924 val T = if_none opt_T TypeInfer.logicT; |
924 val T = if_none opt_T TypeInfer.logicT; |
925 val ctxt' = ctxt |> declare_terms (map (fn x => Free (x, T)) xs); |
925 val ctxt' = ctxt |> declare_terms (map (fn x => Free (x, T)) xs); |