author | sultana |
Thu, 19 Apr 2012 07:25:41 +0100 | |
changeset 47569 | fce9d97a3258 |
parent 47558 | 55b42f9af99d |
child 47570 | df3c9aa6c9dc |
permissions | -rw-r--r-- |
46879 | 1 |
(* Title: HOL/TPTP/TPTP_Parser/tptp_interpret.ML |
46844 | 2 |
Author: Nik Sultana, Cambridge University Computer Laboratory |
3 |
||
4 |
Interprets TPTP problems in Isabelle/HOL. |
|
5 |
*) |
|
6 |
||
7 |
signature TPTP_INTERPRET = |
|
8 |
sig |
|
47515 | 9 |
(*Signature extension: typing information for variables and constants*) |
46844 | 10 |
type var_types = (string * typ option) list |
47515 | 11 |
type const_map = (string * term) list |
46844 | 12 |
|
47515 | 13 |
(*Mapping from TPTP types to Isabelle/HOL types. This map works over all |
14 |
base types. The map must be total wrt TPTP types.*) |
|
46844 | 15 |
type type_map = (TPTP_Syntax.tptp_type * typ) list |
16 |
||
47515 | 17 |
(*Inference info, when available, consists of the name of the inference rule |
46844 | 18 |
and the names of the inferences involved in the reasoning step.*) |
19 |
type inference_info = (string * string list) option |
|
20 |
||
47515 | 21 |
(*A parsed annotated formula is represented as a 5-tuple consisting of |
22 |
the formula's label, its role, the TPTP formula, its Isabelle/HOL meaning, and |
|
23 |
inference info*) |
|
46844 | 24 |
type tptp_formula_meaning = |
47548 | 25 |
string * TPTP_Syntax.role * term * inference_info |
46844 | 26 |
|
27 |
(*In general, the meaning of a TPTP statement (which, through the Include |
|
47515 | 28 |
directive, may include the meaning of an entire TPTP file, is a map from |
29 |
TPTP to Isabelle/HOL types, a map from TPTP constants to their Isabelle/HOL |
|
30 |
counterparts and their types, and a list of interpreted annotated formulas.*) |
|
46844 | 31 |
type tptp_general_meaning = |
32 |
(type_map * const_map * tptp_formula_meaning list) |
|
33 |
||
47515 | 34 |
(*cautious = indicates whether additional checks are made to check |
35 |
that all used types have been declared. |
|
36 |
problem_name = if given then it is used to qualify types & constants*) |
|
46844 | 37 |
type config = |
47515 | 38 |
{cautious : bool, |
47548 | 39 |
problem_name : TPTP_Problem_Name.problem_name option} |
46844 | 40 |
|
47515 | 41 |
(*Generates a fresh Isabelle/HOL type for interpreting a TPTP type in a theory.*) |
42 |
val declare_type : config -> (TPTP_Syntax.tptp_type * string) -> type_map -> |
|
43 |
theory -> type_map * theory |
|
44 |
||
45 |
(*Map TPTP types to Isabelle/HOL types*) |
|
46844 | 46 |
val interpret_type : config -> theory -> type_map -> |
47 |
TPTP_Syntax.tptp_type -> typ |
|
48 |
||
47515 | 49 |
(*Map TPTP terms to Isabelle/HOL terms*) |
47511 | 50 |
val interpret_term : bool -> config -> TPTP_Syntax.language -> theory -> |
51 |
const_map -> var_types -> type_map -> TPTP_Syntax.tptp_term -> |
|
52 |
term * theory |
|
53 |
||
54 |
val interpret_formula : config -> TPTP_Syntax.language -> const_map -> |
|
55 |
var_types -> type_map -> TPTP_Syntax.tptp_formula -> theory -> |
|
56 |
term * theory |
|
57 |
||
47515 | 58 |
(*Interpret a TPTP line: return a "tptp_general_meaning" for that line, |
59 |
as well as an updated Isabelle theory including any types & constants |
|
60 |
which were specified in that line. |
|
46844 | 61 |
Note that type/constant declarations do not result in any formulas being |
47515 | 62 |
returned. A typical TPTP line might update the theory, and/or return one or |
63 |
more formulas. For instance, the "include" directive may update the theory |
|
64 |
and also return a list of formulas from the included file. |
|
46844 | 65 |
Arguments: |
47515 | 66 |
config = (see above) |
67 |
inclusion list = names of annotated formulas to interpret (since "include" |
|
68 |
directive can be selective wrt to such names) |
|
47360 | 69 |
type_map = mapping of TPTP-types to Isabelle/HOL types. This argument may be |
46844 | 70 |
given to force a specific mapping: this is usually done for using an |
47360 | 71 |
imported TPTP problem in Isar. |
46844 | 72 |
const_map = as previous, but for constants. |
47360 | 73 |
path_prefix = path where TPTP problems etc are located (to help the "include" |
46844 | 74 |
directive find the files. |
47515 | 75 |
line = parsed TPTP line |
46844 | 76 |
thy = theory where interpreted info will be stored. |
77 |
*) |
|
47511 | 78 |
val interpret_line : config -> string list -> type_map -> const_map -> |
46844 | 79 |
Path.T -> TPTP_Syntax.tptp_line -> theory -> tptp_general_meaning * theory |
80 |
||
81 |
(*Like "interpret_line" above, but works over a whole parsed problem. |
|
82 |
Arguments: |
|
47515 | 83 |
config = as previously |
84 |
inclusion list = as previously |
|
85 |
path_prefix = as previously |
|
86 |
lines = parsed TPTP syntax |
|
87 |
type_map = as previously |
|
88 |
const_map = as previously |
|
89 |
thy = as previously |
|
46844 | 90 |
*) |
47519 | 91 |
val interpret_problem : config -> string list -> Path.T -> |
46844 | 92 |
TPTP_Syntax.tptp_line list -> type_map -> const_map -> theory -> |
93 |
tptp_general_meaning * theory |
|
94 |
||
47515 | 95 |
(*Like "interpret_problem" above, but it is given a filename rather than |
46844 | 96 |
a parsed problem.*) |
97 |
val interpret_file : bool -> Path.T -> Path.T -> type_map -> const_map -> |
|
98 |
theory -> tptp_general_meaning * theory |
|
99 |
||
47569
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47558
diff
changeset
|
100 |
type position = string * int * int |
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47558
diff
changeset
|
101 |
exception MISINTERPRET of position list * exn |
46844 | 102 |
exception MISINTERPRET_FORMULA of string * TPTP_Syntax.tptp_formula |
103 |
exception MISINTERPRET_SYMBOL of string * TPTP_Syntax.symbol |
|
104 |
exception MISINTERPRET_TERM of string * TPTP_Syntax.tptp_term |
|
105 |
exception MISINTERPRET_TYPE of string * TPTP_Syntax.tptp_type |
|
106 |
||
47515 | 107 |
val import_file : bool -> Path.T -> Path.T -> type_map -> const_map -> |
108 |
theory -> theory |
|
109 |
||
110 |
(*Imported TPTP files are stored as "manifests" in the theory.*) |
|
111 |
type manifest = TPTP_Problem_Name.problem_name * tptp_general_meaning |
|
112 |
val get_manifests : theory -> manifest list |
|
46844 | 113 |
|
114 |
(*Returns the list of all files included in a directory and its |
|
115 |
subdirectories. This is only used for testing the parser/interpreter against |
|
47360 | 116 |
all TPTP problems.*) |
46844 | 117 |
val get_file_list : Path.T -> Path.T list |
118 |
end |
|
119 |
||
120 |
structure TPTP_Interpret : TPTP_INTERPRET = |
|
121 |
struct |
|
122 |
||
123 |
open TPTP_Syntax |
|
47569
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47558
diff
changeset
|
124 |
type position = string * int * int |
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47558
diff
changeset
|
125 |
exception MISINTERPRET of position list * exn |
46844 | 126 |
exception MISINTERPRET_FORMULA of string * TPTP_Syntax.tptp_formula |
127 |
exception MISINTERPRET_SYMBOL of string * TPTP_Syntax.symbol |
|
128 |
exception MISINTERPRET_TERM of string * TPTP_Syntax.tptp_term |
|
129 |
exception MISINTERPRET_TYPE of string * TPTP_Syntax.tptp_type |
|
130 |
||
47515 | 131 |
|
46844 | 132 |
(* General stuff *) |
133 |
||
134 |
type config = |
|
47515 | 135 |
{cautious : bool, |
136 |
problem_name : TPTP_Problem_Name.problem_name option} |
|
137 |
||
46844 | 138 |
|
139 |
(* Interpretation *) |
|
140 |
||
141 |
(** Signatures and other type abbrevations **) |
|
142 |
||
143 |
type const_map = (string * term) list |
|
144 |
type var_types = (string * typ option) list |
|
145 |
type type_map = (TPTP_Syntax.tptp_type * typ) list |
|
146 |
type inference_info = (string * string list) option |
|
147 |
type tptp_formula_meaning = |
|
47548 | 148 |
string * TPTP_Syntax.role * term * inference_info |
46844 | 149 |
type tptp_general_meaning = |
150 |
(type_map * const_map * tptp_formula_meaning list) |
|
151 |
||
152 |
type manifest = TPTP_Problem_Name.problem_name * tptp_general_meaning |
|
153 |
structure TPTP_Data = Theory_Data |
|
154 |
(type T = manifest list |
|
155 |
val empty = [] |
|
156 |
val extend = I |
|
47332
360e080fd13e
dealing with SMLNJ errors 'value type in structure doesn't match signature spec' (which originated from lack of type generalisation) and 'unresolved flex record' wrt tptp_interpret
sultana
parents:
46961
diff
changeset
|
157 |
(*SMLNJ complains if non-expanded form used below*) |
360e080fd13e
dealing with SMLNJ errors 'value type in structure doesn't match signature spec' (which originated from lack of type generalisation) and 'unresolved flex record' wrt tptp_interpret
sultana
parents:
46961
diff
changeset
|
158 |
fun merge v = Library.merge (op =) v) |
46844 | 159 |
val get_manifests = TPTP_Data.get |
160 |
||
161 |
||
162 |
(** Adding types to a signature **) |
|
163 |
||
47514 | 164 |
(*transform quoted names into acceptable ASCII strings*) |
165 |
fun alphanumerate c = |
|
166 |
let |
|
167 |
val c' = ord c |
|
168 |
val out_of_range = |
|
169 |
((c' > 64) andalso (c' < 91)) orelse ((c' > 96) |
|
170 |
andalso (c' < 123)) orelse ((c' > 47) andalso (c' < 58)) |
|
171 |
in |
|
172 |
if (not out_of_range) andalso (not (c = "_")) then |
|
173 |
"_nom_" ^ Int.toString (ord c) ^ "_" |
|
174 |
else c |
|
175 |
end |
|
176 |
fun alphanumerated_name prefix name = |
|
177 |
prefix ^ (raw_explode #> map alphanumerate #> implode) name |
|
178 |
||
47332
360e080fd13e
dealing with SMLNJ errors 'value type in structure doesn't match signature spec' (which originated from lack of type generalisation) and 'unresolved flex record' wrt tptp_interpret
sultana
parents:
46961
diff
changeset
|
179 |
(*SMLNJ complains if type annotation not used below*) |
360e080fd13e
dealing with SMLNJ errors 'value type in structure doesn't match signature spec' (which originated from lack of type generalisation) and 'unresolved flex record' wrt tptp_interpret
sultana
parents:
46961
diff
changeset
|
180 |
fun mk_binding (config : config) ident = |
46844 | 181 |
let |
47514 | 182 |
val pre_binding = Binding.name (alphanumerated_name "bnd_" ident) |
46844 | 183 |
in |
184 |
case #problem_name config of |
|
185 |
NONE => pre_binding |
|
186 |
| SOME prob => |
|
187 |
Binding.qualify |
|
188 |
false |
|
189 |
(TPTP_Problem_Name.mangle_problem_name prob) |
|
190 |
pre_binding |
|
191 |
end |
|
192 |
||
47548 | 193 |
fun type_exists config thy ty_name = |
194 |
Sign.declared_tyname thy (Sign.full_name thy (mk_binding config ty_name)) |
|
195 |
||
46844 | 196 |
(*Returns updated theory and the name of the final type's name -- i.e. if the |
197 |
original name is already taken then the function looks for an available |
|
198 |
alternative. It also returns an updated type_map if one has been passed to it.*) |
|
199 |
fun declare_type (config : config) (thf_type, type_name) ty_map thy = |
|
47548 | 200 |
if type_exists config thy type_name then |
46844 | 201 |
raise MISINTERPRET_TYPE ("Type already exists", Atom_type type_name) |
202 |
else |
|
203 |
let |
|
204 |
val binding = mk_binding config type_name |
|
205 |
val final_fqn = Sign.full_name thy binding |
|
47510 | 206 |
val thy' = |
207 |
Typedecl.typedecl_global (mk_binding config type_name, [], NoSyn) thy |
|
208 |
|> snd |
|
46844 | 209 |
val typ_map_entry = (thf_type, (Type (final_fqn, []))) |
210 |
val ty_map' = typ_map_entry :: ty_map |
|
211 |
in (ty_map', thy') end |
|
212 |
||
213 |
||
214 |
(** Adding constants to signature **) |
|
215 |
||
216 |
fun full_name thy config const_name = |
|
217 |
Sign.full_name thy (mk_binding config const_name) |
|
218 |
||
219 |
fun const_exists config thy const_name = |
|
220 |
Sign.declared_const thy (full_name thy config const_name) |
|
221 |
||
222 |
fun declare_constant config const_name ty thy = |
|
223 |
if const_exists config thy const_name then |
|
224 |
raise MISINTERPRET_TERM |
|
225 |
("Const already declared", Term_Func (Uninterpreted const_name, [])) |
|
226 |
else |
|
227 |
Theory.specify_const |
|
228 |
((mk_binding config const_name, ty), NoSyn) thy |
|
229 |
||
230 |
||
47515 | 231 |
(** Interpretation functions **) |
46844 | 232 |
|
233 |
(*Types in THF are encoded as formulas. This function translates them to type form.*) |
|
234 |
(*FIXME possibly incomplete hack*) |
|
235 |
fun fmlatype_to_type (Atom (THF_Atom_term (Term_Func (TypeSymbol typ, [])))) = |
|
236 |
Defined_type typ |
|
237 |
| fmlatype_to_type (Atom (THF_Atom_term (Term_Func (Uninterpreted str, [])))) = |
|
238 |
Atom_type str |
|
47360 | 239 |
| fmlatype_to_type (Type_fmla (Fn_type (ty1, ty2))) = |
46844 | 240 |
let |
241 |
val ty1' = case ty1 of |
|
47360 | 242 |
Fn_type _ => fmlatype_to_type (Type_fmla ty1) |
46844 | 243 |
| Fmla_type ty1 => fmlatype_to_type ty1 |
244 |
val ty2' = case ty2 of |
|
47360 | 245 |
Fn_type _ => fmlatype_to_type (Type_fmla ty2) |
46844 | 246 |
| Fmla_type ty2 => fmlatype_to_type ty2 |
247 |
in Fn_type (ty1', ty2') end |
|
248 |
||
249 |
fun interpret_type config thy type_map thf_ty = |
|
250 |
let |
|
251 |
fun lookup_type ty_map thf_ty = |
|
252 |
(case AList.lookup (op =) ty_map thf_ty of |
|
253 |
NONE => |
|
254 |
raise MISINTERPRET_TYPE |
|
47510 | 255 |
("Could not find the interpretation of this TPTP type in the \ |
256 |
\mapping to Isabelle/HOL", thf_ty) |
|
46844 | 257 |
| SOME ty => ty) |
258 |
in |
|
47548 | 259 |
case thf_ty of |
46844 | 260 |
Prod_type (thf_ty1, thf_ty2) => |
261 |
Type ("Product_Type.prod", |
|
262 |
[interpret_type config thy type_map thf_ty1, |
|
263 |
interpret_type config thy type_map thf_ty2]) |
|
264 |
| Fn_type (thf_ty1, thf_ty2) => |
|
265 |
Type ("fun", |
|
266 |
[interpret_type config thy type_map thf_ty1, |
|
267 |
interpret_type config thy type_map thf_ty2]) |
|
268 |
| Atom_type _ => |
|
269 |
lookup_type type_map thf_ty |
|
270 |
| Defined_type tptp_base_type => |
|
271 |
(case tptp_base_type of |
|
47519 | 272 |
Type_Ind => @{typ ind} |
46844 | 273 |
| Type_Bool => HOLogic.boolT |
47510 | 274 |
| Type_Type => raise MISINTERPRET_TYPE ("No type interpretation", thf_ty) |
46844 | 275 |
| Type_Int => Type ("Int.int", []) |
276 |
(*FIXME these types are currently unsupported, so they're treated as |
|
277 |
individuals*) |
|
278 |
| Type_Rat => |
|
279 |
interpret_type config thy type_map (Defined_type Type_Ind) |
|
280 |
| Type_Real => |
|
281 |
interpret_type config thy type_map (Defined_type Type_Ind) |
|
282 |
) |
|
283 |
| Sum_type _ => |
|
284 |
raise MISINTERPRET_TYPE (*FIXME*) |
|
285 |
("No type interpretation (sum type)", thf_ty) |
|
286 |
| Fmla_type tptp_ty => |
|
287 |
fmlatype_to_type tptp_ty |
|
288 |
|> interpret_type config thy type_map |
|
289 |
| Subtype _ => |
|
290 |
raise MISINTERPRET_TYPE (*FIXME*) |
|
291 |
("No type interpretation (subtype)", thf_ty) |
|
292 |
end |
|
293 |
||
294 |
fun the_const config thy language const_map_payload str = |
|
295 |
if language = THF then |
|
296 |
(case AList.lookup (op =) const_map_payload str of |
|
297 |
NONE => raise MISINTERPRET_TERM |
|
47510 | 298 |
("Could not find the interpretation of this constant in the \ |
299 |
\mapping to Isabelle/HOL", Term_Func (Uninterpreted str, [])) |
|
46844 | 300 |
| SOME t => t) |
301 |
else |
|
302 |
if const_exists config thy str then |
|
303 |
Sign.mk_const thy ((Sign.full_name thy (mk_binding config str)), []) |
|
304 |
else raise MISINTERPRET_TERM |
|
47510 | 305 |
("Could not find the interpretation of this constant in the \ |
306 |
\mapping to Isabelle/HOL", Term_Func (Uninterpreted str, [])) |
|
46844 | 307 |
|
308 |
(*Eta-expands Isabelle/HOL binary function. |
|
309 |
"str" is the name of a polymorphic constant in Isabelle/HOL*) |
|
310 |
fun mk_fun str = |
|
311 |
(Const (str, Term.dummyT) $ Bound 1 $ Bound 0) |
|
312 |
|> (Term.absdummy Term.dummyT #> Term.absdummy Term.dummyT) |
|
313 |
(*As above, but swaps the function's arguments*) |
|
314 |
fun mk_swapped_fun str = |
|
315 |
(Const (str, Term.dummyT) $ Bound 0 $ Bound 1) |
|
316 |
|> (Term.absdummy Term.dummyT #> Term.absdummy Term.dummyT) |
|
317 |
||
47360 | 318 |
fun dummy_term () = |
46844 | 319 |
HOLogic.choice_const Term.dummyT $ Term.absdummy Term.dummyT @{term "True"} |
320 |
||
321 |
fun interpret_symbol config thy language const_map symb = |
|
322 |
case symb of |
|
323 |
Uninterpreted n => |
|
324 |
(*Constant would have been added to the map at the time of |
|
325 |
declaration*) |
|
326 |
the_const config thy language const_map n |
|
327 |
| Interpreted_ExtraLogic interpreted_symbol => |
|
328 |
(case interpreted_symbol of (*FIXME incomplete, |
|
329 |
and doesn't work with $i*) |
|
330 |
Sum => mk_fun @{const_name Groups.plus} |
|
331 |
| UMinus => |
|
332 |
(Const (@{const_name Groups.uminus}, Term.dummyT) $ Bound 0) |
|
333 |
|> Term.absdummy Term.dummyT |
|
334 |
| Difference => mk_fun @{const_name Groups.minus} |
|
335 |
| Product => mk_fun @{const_name Groups.times} |
|
336 |
| Quotient => mk_fun @{const_name Fields.divide} |
|
337 |
| Less => mk_fun @{const_name Orderings.less} |
|
338 |
| LessEq => mk_fun @{const_name Orderings.less_eq} |
|
339 |
| Greater => mk_swapped_fun @{const_name Orderings.less} |
|
340 |
(*FIXME would be nicer to expand "greater" |
|
341 |
and "greater_eq" abbreviations*) |
|
342 |
| GreaterEq => mk_swapped_fun @{const_name Orderings.less_eq} |
|
343 |
(* FIXME todo |
|
344 |
| Quotient_E | Quotient_T | Quotient_F | Remainder_E | Remainder_T |
|
345 |
| Remainder_F | Floor | Ceiling | Truncate | Round | To_Int | To_Rat |
|
346 |
| To_Real | EvalEq | Is_Int | Is_Rat*) |
|
347 |
| Apply => raise MISINTERPRET_SYMBOL ("Malformed term?", symb) |
|
47360 | 348 |
| _ => dummy_term () |
46844 | 349 |
) |
350 |
| Interpreted_Logic logic_symbol => |
|
351 |
(case logic_symbol of |
|
352 |
Equals => HOLogic.eq_const Term.dummyT |
|
353 |
| NEquals => |
|
354 |
HOLogic.mk_not (HOLogic.eq_const Term.dummyT $ Bound 1 $ Bound 0) |
|
355 |
|> (Term.absdummy Term.dummyT #> Term.absdummy Term.dummyT) |
|
356 |
| Or => HOLogic.disj |
|
357 |
| And => HOLogic.conj |
|
358 |
| Iff => HOLogic.eq_const HOLogic.boolT |
|
359 |
| If => HOLogic.imp |
|
360 |
| Fi => @{term "\<lambda> x. \<lambda> y. y \<longrightarrow> x"} |
|
361 |
| Xor => |
|
362 |
@{term |
|
363 |
"\<lambda> x. \<lambda> y. \<not> (x \<longleftrightarrow> y)"} |
|
364 |
| Nor => @{term "\<lambda> x. \<lambda> y. \<not> (x \<or> y)"} |
|
365 |
| Nand => @{term "\<lambda> x. \<lambda> y. \<not> (x \<and> y)"} |
|
366 |
| Not => HOLogic.Not |
|
367 |
| Op_Forall => HOLogic.all_const Term.dummyT |
|
368 |
| Op_Exists => HOLogic.exists_const Term.dummyT |
|
369 |
| True => @{term "True"} |
|
370 |
| False => @{term "False"} |
|
371 |
) |
|
372 |
| TypeSymbol _ => |
|
373 |
raise MISINTERPRET_SYMBOL |
|
374 |
("Cannot have TypeSymbol in term", symb) |
|
375 |
| System str => |
|
376 |
raise MISINTERPRET_SYMBOL |
|
47510 | 377 |
("Cannot interpret system symbol", symb) |
46844 | 378 |
|
379 |
(*Apply a function to a list of arguments*) |
|
380 |
val mapply = fold (fn x => fn y => y $ x) |
|
381 |
(*As above, but for products*) |
|
382 |
fun mtimes thy = |
|
383 |
fold (fn x => fn y => |
|
384 |
Sign.mk_const thy |
|
385 |
("Product_Type.Pair",[Term.dummyT, Term.dummyT]) $ y $ x) |
|
386 |
||
387 |
(*Adds constants to signature in FOL. "formula_level" means that the constants |
|
388 |
are to be interpreted as predicates, otherwise as functions over individuals.*) |
|
389 |
fun FO_const_types config formula_level type_map tptp_t thy = |
|
390 |
let |
|
391 |
val ind_type = interpret_type config thy type_map (Defined_type Type_Ind) |
|
392 |
val value_type = |
|
393 |
if formula_level then |
|
394 |
interpret_type config thy type_map (Defined_type Type_Bool) |
|
395 |
else ind_type |
|
396 |
in case tptp_t of |
|
397 |
Term_Func (symb, tptp_ts) => |
|
398 |
let |
|
399 |
val thy' = fold (FO_const_types config false type_map) tptp_ts thy |
|
400 |
val ty = fold (fn ty1 => fn ty2 => Type ("fun", [ty1, ty2])) |
|
401 |
(map (fn _ => ind_type) tptp_ts) value_type |
|
402 |
in |
|
403 |
case symb of |
|
404 |
Uninterpreted const_name => |
|
405 |
if const_exists config thy' const_name then thy' |
|
406 |
else snd (declare_constant config const_name ty thy') |
|
407 |
| _ => thy' |
|
408 |
end |
|
409 |
| _ => thy |
|
410 |
end |
|
411 |
||
412 |
(*like FO_const_types but works over symbols*) |
|
413 |
fun symb_const_types config type_map formula_level const_name n_args thy = |
|
414 |
let |
|
415 |
val ind_type = interpret_type config thy type_map (Defined_type Type_Ind) |
|
416 |
val value_type = |
|
417 |
if formula_level then |
|
418 |
interpret_type config thy type_map (Defined_type Type_Bool) |
|
419 |
else interpret_type config thy type_map (Defined_type Type_Ind) |
|
420 |
fun mk_i_fun b n acc = |
|
421 |
if n = 0 then acc b |
|
422 |
else |
|