216 fun abstract_bin abs f t t1 t2 = abstract_sub t (abs t1 ##>> abs t2 #>> f) |
216 fun abstract_bin abs f t t1 t2 = abstract_sub t (abs t1 ##>> abs t2 #>> f) |
217 |
217 |
218 fun abstract_ter abs f t t1 t2 t3 = |
218 fun abstract_ter abs f t t1 t2 t3 = |
219 abstract_sub t (abs t1 ##>> abs t2 ##>> abs t3 #>> (Scan.triple1 #> f)) |
219 abstract_sub t (abs t1 ##>> abs t2 ##>> abs t3 #>> (Scan.triple1 #> f)) |
220 |
220 |
221 fun abstract_lit (\<^const>\<open>HOL.Not\<close> $ t) = abstract_term t #>> HOLogic.mk_not |
221 fun abstract_lit \<^Const>\<open>Not for t\<close> = abstract_term t #>> HOLogic.mk_not |
222 | abstract_lit t = abstract_term t |
222 | abstract_lit t = abstract_term t |
223 |
223 |
224 fun abstract_not abs (t as \<^const>\<open>HOL.Not\<close> $ t1) = |
224 fun abstract_not abs (t as \<^Const_>\<open>Not\<close> $ t1) = |
225 abstract_sub t (abs t1 #>> HOLogic.mk_not) |
225 abstract_sub t (abs t1 #>> HOLogic.mk_not) |
226 | abstract_not _ t = abstract_lit t |
226 | abstract_not _ t = abstract_lit t |
227 |
227 |
228 fun abstract_conj (t as \<^const>\<open>HOL.conj\<close> $ t1 $ t2) = |
228 fun abstract_conj (t as \<^Const_>\<open>conj\<close> $ t1 $ t2) = |
229 abstract_bin abstract_conj HOLogic.mk_conj t t1 t2 |
229 abstract_bin abstract_conj HOLogic.mk_conj t t1 t2 |
230 | abstract_conj t = abstract_lit t |
230 | abstract_conj t = abstract_lit t |
231 |
231 |
232 fun abstract_disj (t as \<^const>\<open>HOL.disj\<close> $ t1 $ t2) = |
232 fun abstract_disj (t as \<^Const_>\<open>disj\<close> $ t1 $ t2) = |
233 abstract_bin abstract_disj HOLogic.mk_disj t t1 t2 |
233 abstract_bin abstract_disj HOLogic.mk_disj t t1 t2 |
234 | abstract_disj t = abstract_lit t |
234 | abstract_disj t = abstract_lit t |
235 |
235 |
236 fun abstract_prop (t as (c as @{const If (bool)}) $ t1 $ t2 $ t3) = |
236 fun abstract_prop (t as (c as \<^Const>\<open>If \<^Type>\<open>bool\<close>\<close>) $ t1 $ t2 $ t3) = |
237 abstract_ter abstract_prop (fn (t1, t2, t3) => c $ t1 $ t2 $ t3) t t1 t2 t3 |
237 abstract_ter abstract_prop (fn (t1, t2, t3) => c $ t1 $ t2 $ t3) t t1 t2 t3 |
238 | abstract_prop (t as \<^const>\<open>HOL.disj\<close> $ t1 $ t2) = |
238 | abstract_prop (t as \<^Const_>\<open>disj\<close> $ t1 $ t2) = |
239 abstract_bin abstract_prop HOLogic.mk_disj t t1 t2 |
239 abstract_bin abstract_prop HOLogic.mk_disj t t1 t2 |
240 | abstract_prop (t as \<^const>\<open>HOL.conj\<close> $ t1 $ t2) = |
240 | abstract_prop (t as \<^Const_>\<open>conj\<close> $ t1 $ t2) = |
241 abstract_bin abstract_prop HOLogic.mk_conj t t1 t2 |
241 abstract_bin abstract_prop HOLogic.mk_conj t t1 t2 |
242 | abstract_prop (t as \<^const>\<open>HOL.implies\<close> $ t1 $ t2) = |
242 | abstract_prop (t as \<^Const_>\<open>implies\<close> $ t1 $ t2) = |
243 abstract_bin abstract_prop HOLogic.mk_imp t t1 t2 |
243 abstract_bin abstract_prop HOLogic.mk_imp t t1 t2 |
244 | abstract_prop (t as \<^term>\<open>HOL.eq :: bool => _\<close> $ t1 $ t2) = |
244 | abstract_prop (t as \<^Const_>\<open>HOL.eq \<^Type>\<open>bool\<close>\<close> $ t1 $ t2) = |
245 abstract_bin abstract_prop HOLogic.mk_eq t t1 t2 |
245 abstract_bin abstract_prop HOLogic.mk_eq t t1 t2 |
246 | abstract_prop t = abstract_not abstract_prop t |
246 | abstract_prop t = abstract_not abstract_prop t |
247 |
247 |
248 fun abstract_arith ctxt u = |
248 fun abstract_arith ctxt u = |
249 let |
249 let |
251 abstract_sub t (abstract_term t) |
251 abstract_sub t (abstract_term t) |
252 | abs (t as (c as Const _) $ Abs (s, T, t')) = |
252 | abs (t as (c as Const _) $ Abs (s, T, t')) = |
253 abstract_sub t (abs t' #>> (fn u' => c $ Abs (s, T, u'))) |
253 abstract_sub t (abs t' #>> (fn u' => c $ Abs (s, T, u'))) |
254 | abs (t as (c as Const (\<^const_name>\<open>If\<close>, _)) $ t1 $ t2 $ t3) = |
254 | abs (t as (c as Const (\<^const_name>\<open>If\<close>, _)) $ t1 $ t2 $ t3) = |
255 abstract_ter abs (fn (t1, t2, t3) => c $ t1 $ t2 $ t3) t t1 t2 t3 |
255 abstract_ter abs (fn (t1, t2, t3) => c $ t1 $ t2 $ t3) t t1 t2 t3 |
256 | abs (t as \<^const>\<open>HOL.Not\<close> $ t1) = abstract_sub t (abs t1 #>> HOLogic.mk_not) |
256 | abs (t as \<^Const_>\<open>Not\<close> $ t1) = abstract_sub t (abs t1 #>> HOLogic.mk_not) |
257 | abs (t as \<^const>\<open>HOL.disj\<close> $ t1 $ t2) = |
257 | abs (t as \<^Const_>\<open>disj\<close> $ t1 $ t2) = |
258 abstract_sub t (abs t1 ##>> abs t2 #>> HOLogic.mk_disj) |
258 abstract_sub t (abs t1 ##>> abs t2 #>> HOLogic.mk_disj) |
259 | abs (t as (c as Const (\<^const_name>\<open>uminus_class.uminus\<close>, _)) $ t1) = |
259 | abs (t as (c as Const (\<^const_name>\<open>uminus_class.uminus\<close>, _)) $ t1) = |
260 abstract_sub t (abs t1 #>> (fn u => c $ u)) |
260 abstract_sub t (abs t1 #>> (fn u => c $ u)) |
261 | abs (t as (c as Const (\<^const_name>\<open>plus_class.plus\<close>, _)) $ t1 $ t2) = |
261 | abs (t as (c as Const (\<^const_name>\<open>plus_class.plus\<close>, _)) $ t1 $ t2) = |
262 abstract_sub t (abs t1 ##>> abs t2 #>> (fn (u1, u2) => c $ u1 $ u2)) |
262 abstract_sub t (abs t1 ##>> abs t2 #>> (fn (u1, u2) => c $ u1 $ u2)) |
280 (case apply_abstracters abs (get_arith_abstracters ctxt) t cx of |
280 (case apply_abstracters abs (get_arith_abstracters ctxt) t cx of |
281 (SOME u, cx') => (u, cx') |
281 (SOME u, cx') => (u, cx') |
282 | (NONE, _) => abstract_term t cx)) |
282 | (NONE, _) => abstract_term t cx)) |
283 in abs u end |
283 in abs u end |
284 |
284 |
285 fun abstract_unit (t as (\<^const>\<open>HOL.Not\<close> $ (\<^const>\<open>HOL.disj\<close> $ t1 $ t2))) = |
285 fun abstract_unit (t as \<^Const_>\<open>Not for \<^Const_>\<open>disj for t1 t2\<close>\<close>) = |
286 abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>> |
286 abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>> |
287 HOLogic.mk_not o HOLogic.mk_disj) |
287 HOLogic.mk_not o HOLogic.mk_disj) |
288 | abstract_unit (t as (\<^const>\<open>HOL.disj\<close> $ t1 $ t2)) = |
288 | abstract_unit (t as \<^Const_>\<open>disj for t1 t2\<close>) = |
289 abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>> |
289 abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>> |
290 HOLogic.mk_disj) |
290 HOLogic.mk_disj) |
291 | abstract_unit (t as (Const(\<^const_name>\<open>HOL.eq\<close>, _) $ t1 $ t2)) = |
291 | abstract_unit (t as (Const(\<^const_name>\<open>HOL.eq\<close>, _) $ t1 $ t2)) = |
292 if fastype_of t1 = \<^typ>\<open>bool\<close> then |
292 if fastype_of t1 = \<^typ>\<open>bool\<close> then |
293 abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>> |
293 abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>> |
294 HOLogic.mk_eq) |
294 HOLogic.mk_eq) |
295 else abstract_lit t |
295 else abstract_lit t |
296 | abstract_unit (t as (\<^const>\<open>HOL.Not\<close> $ (Const(\<^const_name>\<open>HOL.eq\<close>, _) $ t1 $ t2))) = |
296 | abstract_unit (t as \<^Const_>\<open>Not for \<^Const_>\<open>HOL.eq _ for t1 t2\<close>\<close>) = |
297 if fastype_of t1 = \<^typ>\<open>bool\<close> then |
297 if fastype_of t1 = \<^typ>\<open>bool\<close> then |
298 abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>> |
298 abstract_sub t (abstract_unit t1 ##>> abstract_unit t2 #>> |
299 HOLogic.mk_eq #>> HOLogic.mk_not) |
299 HOLogic.mk_eq #>> HOLogic.mk_not) |
300 else abstract_lit t |
300 else abstract_lit t |
301 | abstract_unit (t as (\<^const>\<open>HOL.Not\<close> $ t1)) = |
301 | abstract_unit (t as \<^Const>\<open>Not for t1\<close>) = |
302 abstract_sub t (abstract_unit t1 #>> HOLogic.mk_not) |
302 abstract_sub t (abstract_unit t1 #>> HOLogic.mk_not) |
303 | abstract_unit t = abstract_lit t |
303 | abstract_unit t = abstract_lit t |
304 |
304 |
305 fun abstract_bool (t as (@{const HOL.disj} $ t1 $ t2)) = |
305 fun abstract_bool (t as \<^Const_>\<open>disj for t1 t2\<close>) = |
306 abstract_sub t (abstract_bool t1 ##>> abstract_bool t2 #>> |
306 abstract_sub t (abstract_bool t1 ##>> abstract_bool t2 #>> |
307 HOLogic.mk_disj) |
307 HOLogic.mk_disj) |
308 | abstract_bool (t as (@{const HOL.conj} $ t1 $ t2)) = |
308 | abstract_bool (t as \<^Const_>\<open>conj for t1 t2\<close>) = |
309 abstract_sub t (abstract_bool t1 ##>> abstract_bool t2 #>> |
309 abstract_sub t (abstract_bool t1 ##>> abstract_bool t2 #>> |
310 HOLogic.mk_conj) |
310 HOLogic.mk_conj) |
311 | abstract_bool (t as (Const(@{const_name HOL.eq}, _) $ t1 $ t2)) = |
311 | abstract_bool (t as \<^Const_>\<open>HOL.eq _ for t1 t2\<close>) = |
312 if fastype_of t1 = @{typ bool} then |
312 if fastype_of t1 = @{typ bool} then |
313 abstract_sub t (abstract_bool t1 ##>> abstract_bool t2 #>> |
313 abstract_sub t (abstract_bool t1 ##>> abstract_bool t2 #>> |
314 HOLogic.mk_eq) |
314 HOLogic.mk_eq) |
315 else abstract_lit t |
315 else abstract_lit t |
316 | abstract_bool (t as (@{const HOL.Not} $ t1)) = |
316 | abstract_bool (t as \<^Const_>\<open>Not for t1\<close>) = |
317 abstract_sub t (abstract_bool t1 #>> HOLogic.mk_not) |
317 abstract_sub t (abstract_bool t1 #>> HOLogic.mk_not) |
318 | abstract_bool (t as (@{const HOL.implies} $ t1 $ t2)) = |
318 | abstract_bool (t as \<^Const>\<open>implies for t1 t2\<close>) = |
319 abstract_sub t (abstract_bool t1 ##>> abstract_bool t2 #>> |
319 abstract_sub t (abstract_bool t1 ##>> abstract_bool t2 #>> |
320 HOLogic.mk_imp) |
320 HOLogic.mk_imp) |
321 | abstract_bool t = abstract_lit t |
321 | abstract_bool t = abstract_lit t |
322 |
322 |
323 fun abstract_bool_shallow (t as (@{const HOL.disj} $ t1 $ t2)) = |
323 fun abstract_bool_shallow (t as \<^Const_>\<open>disj for t1 t2\<close>) = |
324 abstract_sub t (abstract_bool_shallow t1 ##>> abstract_bool_shallow t2 #>> |
324 abstract_sub t (abstract_bool_shallow t1 ##>> abstract_bool_shallow t2 #>> |
325 HOLogic.mk_disj) |
325 HOLogic.mk_disj) |
326 | abstract_bool_shallow (t as (@{const HOL.Not} $ t1)) = |
326 | abstract_bool_shallow (t as \<^Const_>\<open>Not for t1\<close>) = |
327 abstract_sub t (abstract_bool_shallow t1 #>> HOLogic.mk_not) |
327 abstract_sub t (abstract_bool_shallow t1 #>> HOLogic.mk_not) |
328 | abstract_bool_shallow t = abstract_term t |
328 | abstract_bool_shallow t = abstract_term t |
329 |
329 |
330 fun abstract_bool_shallow_equivalence (t as (@{const HOL.disj} $ t1 $ t2)) = |
330 fun abstract_bool_shallow_equivalence (t as \<^Const_>\<open>disj for t1 t2\<close>) = |
331 abstract_sub t (abstract_bool_shallow_equivalence t1 ##>> abstract_bool_shallow_equivalence t2 #>> |
331 abstract_sub t (abstract_bool_shallow_equivalence t1 ##>> abstract_bool_shallow_equivalence t2 #>> |
332 HOLogic.mk_disj) |
332 HOLogic.mk_disj) |
333 | abstract_bool_shallow_equivalence (t as (Const(@{const_name HOL.eq}, _) $ t1 $ t2)) = |
333 | abstract_bool_shallow_equivalence (t as \<^Const_>\<open>HOL.eq _ for t1 t2\<close>) = |
334 if fastype_of t1 = @{typ bool} then |
334 if fastype_of t1 = \<^Type>\<open>bool\<close> then |
335 abstract_sub t (abstract_lit t1 ##>> abstract_lit t2 #>> |
335 abstract_sub t (abstract_lit t1 ##>> abstract_lit t2 #>> |
336 HOLogic.mk_eq) |
336 HOLogic.mk_eq) |
337 else abstract_lit t |
337 else abstract_lit t |
338 | abstract_bool_shallow_equivalence (t as (@{const HOL.Not} $ t1)) = |
338 | abstract_bool_shallow_equivalence (t as \<^Const_>\<open>Not for t1\<close>) = |
339 abstract_sub t (abstract_bool_shallow_equivalence t1 #>> HOLogic.mk_not) |
339 abstract_sub t (abstract_bool_shallow_equivalence t1 #>> HOLogic.mk_not) |
340 | abstract_bool_shallow_equivalence t = abstract_lit t |
340 | abstract_bool_shallow_equivalence t = abstract_lit t |
341 |
341 |
342 fun abstract_arith_shallow ctxt u = |
342 fun abstract_arith_shallow ctxt u = |
343 let |
343 let |
345 abstract_sub t (abstract_term t) |
345 abstract_sub t (abstract_term t) |
346 | abs (t as (c as Const _) $ Abs (s, T, t')) = |
346 | abs (t as (c as Const _) $ Abs (s, T, t')) = |
347 abstract_sub t (abs t' #>> (fn u' => c $ Abs (s, T, u'))) |
347 abstract_sub t (abs t' #>> (fn u' => c $ Abs (s, T, u'))) |
348 | abs (t as (Const (\<^const_name>\<open>If\<close>, _)) $ _ $ _ $ _) = |
348 | abs (t as (Const (\<^const_name>\<open>If\<close>, _)) $ _ $ _ $ _) = |
349 abstract_sub t (abstract_term t) |
349 abstract_sub t (abstract_term t) |
350 | abs (t as \<^const>\<open>HOL.Not\<close> $ t1) = abstract_sub t (abs t1 #>> HOLogic.mk_not) |
350 | abs (t as \<^Const>\<open>Not\<close> $ t1) = abstract_sub t (abs t1 #>> HOLogic.mk_not) |
351 | abs (t as \<^const>\<open>HOL.disj\<close> $ t1 $ t2) = |
351 | abs (t as \<^Const>\<open>disj\<close> $ t1 $ t2) = |
352 abstract_sub t (abs t1 ##>> abs t2 #>> HOLogic.mk_disj) |
352 abstract_sub t (abs t1 ##>> abs t2 #>> HOLogic.mk_disj) |
353 | abs (t as (c as Const (\<^const_name>\<open>uminus_class.uminus\<close>, _)) $ t1) = |
353 | abs (t as (c as Const (\<^const_name>\<open>uminus_class.uminus\<close>, _)) $ t1) = |
354 abstract_sub t (abs t1 #>> (fn u => c $ u)) |
354 abstract_sub t (abs t1 #>> (fn u => c $ u)) |
355 | abs (t as (c as Const (\<^const_name>\<open>plus_class.plus\<close>, _)) $ t1 $ t2) = |
355 | abs (t as (c as Const (\<^const_name>\<open>plus_class.plus\<close>, _)) $ t1 $ t2) = |
356 abstract_sub t (abs t1 ##>> abs t2 #>> (fn (u1, u2) => c $ u1 $ u2)) |
356 abstract_sub t (abs t1 ##>> abs t2 #>> (fn (u1, u2) => c $ u1 $ u2)) |