383 val t' = subst_bound (v, t); |
379 val t' = subst_bound (v, t); |
384 val rec_term = regularise t' rty rel lthy2; |
380 val rec_term = regularise t' rty rel lthy2; |
385 in |
381 in |
386 Term.lambda_name (x, v) rec_term |
382 Term.lambda_name (x, v) rec_term |
387 end |
383 end |
|
384 | ((Const (@{const_name "Ex"}, _)) $ (Abs (x, T, t))) => |
|
385 if T = rty then let |
|
386 val ([x'], lthy2) = Variable.variant_fixes [x] lthy; |
|
387 val v = Free (x', rty); |
|
388 val t' = subst_bound (v, t); |
|
389 val rec_term = regularise t' rty rel lthy2; |
|
390 val lam_term = Term.lambda_name (x, v) rec_term; |
|
391 val sub_res_term = tyRel T rty rel lthy; |
|
392 val respects = Const (@{const_name Respects}, (fastype_of sub_res_term) --> T --> @{typ bool}); |
|
393 val res_term = respects $ sub_res_term; |
|
394 val ty = fastype_of lam_term; |
|
395 val rall = Const (@{const_name Bex}, (fastype_of res_term) --> ty --> @{typ bool}); |
|
396 val rall_term = (rall $ res_term) $ lam_term; |
|
397 in |
|
398 rall_term |
|
399 end else let |
|
400 val ([x'], lthy2) = Variable.variant_fixes [x] lthy; |
|
401 val v = Free (x', rty); |
|
402 val t' = subst_bound (v, t); |
|
403 val rec_term = regularise t' rty rel lthy2; |
|
404 in |
|
405 Term.lambda_name (x, v) rec_term |
|
406 end |
388 | _ => trm |
407 | _ => trm |
389 |
408 |
390 *} |
409 *} |
391 term "Ball" |
|
392 term "Ball (Respects (RR)) (\<lambda>x :: trm. true)" |
|
393 |
410 |
394 ML {* |
411 ML {* |
395 cterm_of @{theory} (regularise @{term "\<lambda>x :: trm. x"} @{typ "trm"} @{term "RR"} @{context}); |
412 cterm_of @{theory} (regularise @{term "\<lambda>x :: trm. x"} @{typ "trm"} @{term "RR"} @{context}); |
396 cterm_of @{theory} (regularise @{term "\<forall>x :: trm. true"} @{typ "trm"} @{term "RR"} @{context}) |
413 cterm_of @{theory} (regularise @{term "\<forall>x :: trm. P x"} @{typ "trm"} @{term "RR"} @{context}); |
397 *} |
414 cterm_of @{theory} (regularise @{term "\<exists>x :: trm. P x"} @{typ "trm"} @{term "RR"} @{context}) |
|
415 *} |
|
416 |
|
417 |
|
418 term Respects |
|
419 |
|
420 ML {* |
|
421 fun atomize_thm t = |
|
422 MetaSimplifier.rewrite_rule [ObjectLogic.atomize (cterm_of @{theory} (prop_of t))] t |
|
423 *} |
|
424 |
|
425 ML {* |
|
426 fun meta_quantify t = |
|
427 let |
|
428 val vars = Term.add_vars (prop_of t) []; |
|
429 val cvars = map (fn x => cterm_of @{theory} (Var x)) vars |
|
430 in |
|
431 fold forall_intr cvars t |
|
432 end |
|
433 *} |
|
434 |
|
435 ML {* atomize_thm (meta_quantify @{thm list.induct}) *} |
398 |
436 |
399 (*fun prove_reg trm \<Rightarrow> thm (we might need some facts to do this) |
437 (*fun prove_reg trm \<Rightarrow> thm (we might need some facts to do this) |
400 trm == new_trm |
438 trm == new_trm |
401 *) |
439 *) |
402 |
440 |
403 thm list.induct |
|
404 |
441 |
405 text {* produces the definition for a lifted constant *} |
442 text {* produces the definition for a lifted constant *} |
406 |
443 |
407 ML {* |
444 ML {* |
408 fun get_const_def nconst oconst rty qty lthy = |
445 fun get_const_def nconst oconst rty qty lthy = |