35 val builtin_fun: Proof.context -> string * typ -> term list -> |
35 val builtin_fun: Proof.context -> string * typ -> term list -> |
36 (string * term list) option |
36 (string * term list) option |
37 val is_builtin_fun: Proof.context -> string * typ -> term list -> bool |
37 val is_builtin_fun: Proof.context -> string * typ -> term list -> bool |
38 val is_builtin_pred: Proof.context -> string * typ -> term list -> bool |
38 val is_builtin_pred: Proof.context -> string * typ -> term list -> bool |
39 val is_builtin_conn: Proof.context -> string * typ -> term list -> bool |
39 val is_builtin_conn: Proof.context -> string * typ -> term list -> bool |
|
40 val is_builtin_fun_ext: Proof.context -> string * typ -> term list -> bool |
40 val is_builtin_ext: Proof.context -> string * typ -> term list -> bool |
41 val is_builtin_ext: Proof.context -> string * typ -> term list -> bool |
41 end |
42 end |
42 |
43 |
43 structure SMT_Builtin: SMT_BUILTIN = |
44 structure SMT_Builtin: SMT_BUILTIN = |
44 struct |
45 struct |
76 get_first (find_first match) (U.dict_lookup ttab (C.solver_class_of ctxt)) |
77 get_first (find_first match) (U.dict_lookup ttab (C.solver_class_of ctxt)) |
77 end |
78 end |
78 |
79 |
79 type ('a, 'b) btab = ('a, 'b) ttab Symtab.table |
80 type ('a, 'b) btab = ('a, 'b) ttab Symtab.table |
80 |
81 |
81 fun empty_btab () = Symtab.empty |
|
82 |
|
83 fun insert_btab cs n T f = |
82 fun insert_btab cs n T f = |
84 Symtab.map_default (n, []) (insert_ttab cs T f) |
83 Symtab.map_default (n, []) (insert_ttab cs T f) |
85 |
84 |
86 fun merge_btab btabp = Symtab.join (K merge_ttab) btabp |
85 fun merge_btab btabp = Symtab.join (K merge_ttab) btabp |
87 |
86 |
145 |
144 |
146 (* built-in functions *) |
145 (* built-in functions *) |
147 |
146 |
148 type 'a bfun = Proof.context -> typ -> term list -> 'a |
147 type 'a bfun = Proof.context -> typ -> term list -> 'a |
149 |
148 |
150 fun true3 _ _ _ = true |
|
151 |
|
152 fun raw_add_builtin_fun_ext thy cs n = |
|
153 insert_btab cs n (Sign.the_const_type thy n) (Ext true3) |
|
154 |
|
155 val basic_builtin_fun_names = [ |
|
156 @{const_name SMT.pat}, @{const_name SMT.nopat}, |
|
157 @{const_name SMT.trigger}, @{const_name SMT.weight}] |
|
158 |
|
159 type builtin_funcs = (bool bfun, (string * term list) option bfun) btab |
|
160 |
|
161 fun basic_builtin_funcs () : builtin_funcs = |
|
162 empty_btab () |
|
163 |> fold (raw_add_builtin_fun_ext @{theory} U.basicC) basic_builtin_fun_names |
|
164 (* FIXME: SMT_Normalize should check that they are properly used *) |
|
165 |
|
166 structure Builtin_Funcs = Generic_Data |
149 structure Builtin_Funcs = Generic_Data |
167 ( |
150 ( |
168 type T = builtin_funcs |
151 type T = (bool bfun, (string * term list) option bfun) btab |
169 val empty = basic_builtin_funcs () |
152 val empty = Symtab.empty |
170 val extend = I |
153 val extend = I |
171 val merge = merge_btab |
154 val merge = merge_btab |
172 ) |
155 ) |
173 |
156 |
174 fun add_builtin_fun cs ((n, T), f) = |
157 fun add_builtin_fun cs ((n, T), f) = |
178 add_builtin_fun cs (Term.dest_Const t, fn _ => fn _ => SOME o pair n) |
161 add_builtin_fun cs (Term.dest_Const t, fn _ => fn _ => SOME o pair n) |
179 |
162 |
180 fun add_builtin_fun_ext ((n, T), f) = |
163 fun add_builtin_fun_ext ((n, T), f) = |
181 Builtin_Funcs.map (insert_btab U.basicC n T (Ext f)) |
164 Builtin_Funcs.map (insert_btab U.basicC n T (Ext f)) |
182 |
165 |
183 fun add_builtin_fun_ext' c = add_builtin_fun_ext (c, true3) |
166 fun add_builtin_fun_ext' c = |
|
167 add_builtin_fun_ext (c, fn _ => fn _ => fn _ => true) |
184 |
168 |
185 fun add_builtin_fun_ext'' n context = |
169 fun add_builtin_fun_ext'' n context = |
186 let val thy = Context.theory_of context |
170 let val thy = Context.theory_of context |
187 in add_builtin_fun_ext' (n, Sign.the_const_type thy n) context end |
171 in add_builtin_fun_ext' (n, Sign.the_const_type thy n) context end |
188 |
172 |