69 val proxy_table : (string * (string * (thm * (string * string)))) list |
69 val proxy_table : (string * (string * (thm * (string * string)))) list |
70 val proxify_const : string -> (string * string) option |
70 val proxify_const : string -> (string * string) option |
71 val invert_const : string -> string |
71 val invert_const : string -> string |
72 val unproxify_const : string -> string |
72 val unproxify_const : string -> string |
73 val new_skolem_var_name_from_const : string -> string |
73 val new_skolem_var_name_from_const : string -> string |
74 val num_type_args : theory -> string -> int |
|
75 val atp_irrelevant_consts : string list |
74 val atp_irrelevant_consts : string list |
76 val atp_schematic_consts_of : term -> typ list Symtab.table |
75 val atp_schematic_consts_of : term -> typ list Symtab.table |
77 val is_locality_global : locality -> bool |
76 val is_locality_global : locality -> bool |
78 val type_enc_from_string : string -> type_enc |
77 val type_enc_from_string : string -> type_enc |
79 val is_type_enc_higher_order : type_enc -> bool |
78 val is_type_enc_higher_order : type_enc -> bool |
124 val tfree_prefix = "t_" |
123 val tfree_prefix = "t_" |
125 val const_prefix = "c_" |
124 val const_prefix = "c_" |
126 val type_const_prefix = "tc_" |
125 val type_const_prefix = "tc_" |
127 val class_prefix = "cl_" |
126 val class_prefix = "cl_" |
128 |
127 |
|
128 (* TODO: Use a more descriptive prefix in "SMT_Translate.lift_lambdas". *) |
|
129 val lambda_lifted_prefix = Name.uu |
|
130 |
129 val skolem_const_prefix = "ATP" ^ Long_Name.separator ^ "Sko" |
131 val skolem_const_prefix = "ATP" ^ Long_Name.separator ^ "Sko" |
130 val old_skolem_const_prefix = skolem_const_prefix ^ "o" |
132 val old_skolem_const_prefix = skolem_const_prefix ^ "o" |
131 val new_skolem_const_prefix = skolem_const_prefix ^ "n" |
133 val new_skolem_const_prefix = skolem_const_prefix ^ "n" |
132 |
134 |
133 val type_decl_prefix = "ty_" |
135 val type_decl_prefix = "ty_" |
299 fun new_skolem_var_name_from_const s = |
301 fun new_skolem_var_name_from_const s = |
300 let val ss = s |> space_explode Long_Name.separator in |
302 let val ss = s |> space_explode Long_Name.separator in |
301 nth ss (length ss - 2) |
303 nth ss (length ss - 2) |
302 end |
304 end |
303 |
305 |
304 (* The number of type arguments of a constant, zero if it's monomorphic. For |
|
305 (instances of) Skolem pseudoconstants, this information is encoded in the |
|
306 constant name. *) |
|
307 fun num_type_args thy s = |
|
308 if String.isPrefix skolem_const_prefix s then |
|
309 s |> space_explode Long_Name.separator |> List.last |> Int.fromString |> the |
|
310 else |
|
311 (s, Sign.the_const_type thy s) |> Sign.const_typargs thy |> length |
|
312 |
|
313 (* These are either simplified away by "Meson.presimplify" (most of the time) or |
306 (* These are either simplified away by "Meson.presimplify" (most of the time) or |
314 handled specially via "fFalse", "fTrue", ..., "fequal". *) |
307 handled specially via "fFalse", "fTrue", ..., "fequal". *) |
315 val atp_irrelevant_consts = |
308 val atp_irrelevant_consts = |
316 [@{const_name False}, @{const_name True}, @{const_name Not}, |
309 [@{const_name False}, @{const_name True}, @{const_name Not}, |
317 @{const_name conj}, @{const_name disj}, @{const_name implies}, |
310 @{const_name conj}, @{const_name disj}, @{const_name implies}, |
477 let |
470 let |
478 val (P', P_atomics_Ts) = iterm_from_term thy bs P |
471 val (P', P_atomics_Ts) = iterm_from_term thy bs P |
479 val (Q', Q_atomics_Ts) = iterm_from_term thy bs Q |
472 val (Q', Q_atomics_Ts) = iterm_from_term thy bs Q |
480 in (IApp (P', Q'), union (op =) P_atomics_Ts Q_atomics_Ts) end |
473 in (IApp (P', Q'), union (op =) P_atomics_Ts Q_atomics_Ts) end |
481 | iterm_from_term thy _ (Const (c, T)) = |
474 | iterm_from_term thy _ (Const (c, T)) = |
482 let |
475 (IConst (`make_fixed_const c, T, |
483 val tvar_list = |
476 if String.isPrefix old_skolem_const_prefix c then |
484 (if String.isPrefix old_skolem_const_prefix c then |
477 [] |> Term.add_tvarsT T |> map TVar |
485 [] |> Term.add_tvarsT T |> map TVar |
478 else |
486 else |
479 (c, T) |> Sign.const_typargs thy), |
487 (c, T) |> Sign.const_typargs thy) |
480 atyps_of T) |
488 val c' = IConst (`make_fixed_const c, T, tvar_list) |
481 | iterm_from_term _ _ (Free (s, T)) = |
489 in (c', atyps_of T) end |
482 (IConst (`make_fixed_var s, T, |
490 | iterm_from_term _ _ (Free (v, T)) = |
483 if String.isPrefix lambda_lifted_prefix s then [T] else []), |
491 (IConst (`make_fixed_var v, T, []), atyps_of T) |
484 atyps_of T) |
492 | iterm_from_term _ _ (Var (v as (s, _), T)) = |
485 | iterm_from_term _ _ (Var (v as (s, _), T)) = |
493 (if String.isPrefix Meson_Clausify.new_skolem_var_prefix s then |
486 (if String.isPrefix Meson_Clausify.new_skolem_var_prefix s then |
494 let |
487 let |
495 val Ts = T |> strip_type |> swap |> op :: |
488 val Ts = T |> strip_type |> swap |> op :: |
496 val s' = new_skolem_const_name s (length Ts) |
489 val s' = new_skolem_const_name s (length Ts) |
1412 |
1405 |
1413 fun fold_type_constrs f (Type (s, Ts)) x = |
1406 fun fold_type_constrs f (Type (s, Ts)) x = |
1414 fold (fold_type_constrs f) Ts (f (s, x)) |
1407 fold (fold_type_constrs f) Ts (f (s, x)) |
1415 | fold_type_constrs _ _ x = x |
1408 | fold_type_constrs _ _ x = x |
1416 |
1409 |
1417 (*Type constructors used to instantiate overloaded constants are the only ones needed.*) |
1410 (* Type constructors used to instantiate overloaded constants are the only ones |
|
1411 needed. *) |
1418 fun add_type_constrs_in_term thy = |
1412 fun add_type_constrs_in_term thy = |
1419 let |
1413 let |
1420 fun add (Const (@{const_name Meson.skolem}, _) $ _) = I |
1414 fun add (Const (@{const_name Meson.skolem}, _) $ _) = I |
1421 | add (t $ u) = add t #> add u |
1415 | add (t $ u) = add t #> add u |
1422 | add (Const (x as (s, _))) = |
1416 | add (Const (x as (s, _))) = |
1423 if String.isPrefix skolem_const_prefix s then I |
1417 if String.isPrefix skolem_const_prefix s then I |
1424 else x |> Sign.const_typargs thy |> fold (fold_type_constrs set_insert) |
1418 else x |> Sign.const_typargs thy |> fold (fold_type_constrs set_insert) |
|
1419 | add (Free (s, T)) = |
|
1420 if String.isPrefix lambda_lifted_prefix s then |
|
1421 T |> fold_type_constrs set_insert |
|
1422 else |
|
1423 I |
1425 | add (Abs (_, _, u)) = add u |
1424 | add (Abs (_, _, u)) = add u |
1426 | add _ = I |
1425 | add _ = I |
1427 in add end |
1426 in add end |
1428 |
1427 |
1429 fun type_constrs_of_terms thy ts = |
1428 fun type_constrs_of_terms thy ts = |
1731 val num_args = length arg_Ts |
1730 val num_args = length arg_Ts |
1732 val bound_names = |
1731 val bound_names = |
1733 1 upto num_args |> map (`I o make_bound_var o string_of_int) |
1732 1 upto num_args |> map (`I o make_bound_var o string_of_int) |
1734 val bounds = |
1733 val bounds = |
1735 bound_names ~~ arg_Ts |> map (fn (name, T) => IConst (name, T, [])) |
1734 bound_names ~~ arg_Ts |> map (fn (name, T) => IConst (name, T, [])) |
1736 val sym_needs_arg_types = exists (curry (op =) dummyT) T_args) |
1735 val sym_needs_arg_types = exists (curry (op =) dummyT) T_args |
1737 fun should_keep_arg_type T = |
1736 fun should_keep_arg_type T = |
1738 sym_needs_arg_types orelse |
1737 sym_needs_arg_types orelse |
1739 not (should_predicate_on_type ctxt nonmono_Ts type_enc (K false) T) |
1738 not (should_predicate_on_type ctxt nonmono_Ts type_enc (K false) T) |
1740 val bound_Ts = |
1739 val bound_Ts = |
1741 arg_Ts |> map (fn T => if should_keep_arg_type T then SOME T else NONE) |
1740 arg_Ts |> map (fn T => if should_keep_arg_type T then SOME T else NONE) |