14 val nat_subscript : int -> string |
14 val nat_subscript : int -> string |
15 val unyxml : string -> string |
15 val unyxml : string -> string |
16 val maybe_quote : string -> string |
16 val maybe_quote : string -> string |
17 val string_from_ext_time : bool * Time.time -> string |
17 val string_from_ext_time : bool * Time.time -> string |
18 val string_from_time : Time.time -> string |
18 val string_from_time : Time.time -> string |
19 val type_instance : Proof.context -> typ -> typ -> bool |
19 val type_instance : theory -> typ -> typ -> bool |
20 val type_generalization : Proof.context -> typ -> typ -> bool |
20 val type_generalization : theory -> typ -> typ -> bool |
21 val type_intersect : Proof.context -> typ -> typ -> bool |
21 val type_intersect : theory -> typ -> typ -> bool |
22 val type_equiv : Proof.context -> typ * typ -> bool |
22 val type_equiv : theory -> typ * typ -> bool |
23 val varify_type : Proof.context -> typ -> typ |
23 val varify_type : Proof.context -> typ -> typ |
24 val instantiate_type : theory -> typ -> typ -> typ -> typ |
24 val instantiate_type : theory -> typ -> typ -> typ -> typ |
25 val varify_and_instantiate_type : Proof.context -> typ -> typ -> typ -> typ |
25 val varify_and_instantiate_type : Proof.context -> typ -> typ -> typ -> typ |
26 val typ_of_dtyp : Datatype.descr -> (Datatype.dtyp * typ) list -> Datatype.dtyp -> typ |
26 val typ_of_dtyp : Datatype.descr -> (Datatype.dtyp * typ) list -> Datatype.dtyp -> typ |
27 val is_type_surely_finite : Proof.context -> typ -> bool |
27 val is_type_surely_finite : Proof.context -> typ -> bool |
121 string_of_real (0.01 * Real.fromInt (ms div 10)) ^ " s") |
121 string_of_real (0.01 * Real.fromInt (ms div 10)) ^ " s") |
122 end |
122 end |
123 |
123 |
124 val string_from_time = string_from_ext_time o pair false |
124 val string_from_time = string_from_ext_time o pair false |
125 |
125 |
126 fun type_instance ctxt T T' = |
126 fun type_instance thy T T' = Sign.typ_instance thy (T, T') |
127 Sign.typ_instance (Proof_Context.theory_of ctxt) (T, T') |
127 fun type_generalization thy T T' = Sign.typ_instance thy (T', T) |
128 fun type_generalization ctxt T T' = type_instance ctxt T' T |
128 fun type_intersect thy T T' = |
129 fun type_intersect ctxt T T' = |
129 can (Sign.typ_unify thy (T, Logic.incr_tvar (maxidx_of_typ T + 1) T')) |
130 can (Sign.typ_unify (Proof_Context.theory_of ctxt) |
|
131 (T, Logic.incr_tvar (maxidx_of_typ T + 1) T')) |
|
132 (Vartab.empty, 0) |
130 (Vartab.empty, 0) |
133 val type_equiv = Sign.typ_equiv o Proof_Context.theory_of |
131 val type_equiv = Sign.typ_equiv |
134 |
132 |
135 fun varify_type ctxt T = |
133 fun varify_type ctxt T = |
136 Variable.polymorphic_types ctxt [Const (@{const_name undefined}, T)] |
134 Variable.polymorphic_types ctxt [Const (@{const_name undefined}, T)] |
137 |> snd |> the_single |> dest_Const |> snd |
135 |> snd |> the_single |> dest_Const |> snd |
138 |
136 |
175 val thy = Proof_Context.theory_of ctxt |
173 val thy = Proof_Context.theory_of ctxt |
176 val max = 2 (* 1 would be too small for the "fun" case *) |
174 val max = 2 (* 1 would be too small for the "fun" case *) |
177 fun aux slack avoid T = |
175 fun aux slack avoid T = |
178 if member (op =) avoid T then |
176 if member (op =) avoid T then |
179 0 |
177 0 |
180 else case AList.lookup (type_equiv ctxt) assigns T of |
178 else case AList.lookup (type_equiv thy) assigns T of |
181 SOME k => k |
179 SOME k => k |
182 | NONE => |
180 | NONE => |
183 case T of |
181 case T of |
184 Type (@{type_name fun}, [T1, T2]) => |
182 Type (@{type_name fun}, [T1, T2]) => |
185 (case (aux slack avoid T1, aux slack avoid T2) of |
183 (case (aux slack avoid T1, aux slack avoid T2) of |