23489
|
1 |
(* Title: HOL/Tools/Qelim/qelim.ML
|
23466
|
2 |
ID: $Id$
|
|
3 |
Author: Amine Chaieb and Tobias Nipkow, TU Muenchen
|
|
4 |
|
23489
|
5 |
Proof protocoling and proof generation for multiple quantified
|
|
6 |
formulae.
|
23466
|
7 |
*)
|
|
8 |
|
|
9 |
signature QELIM =
|
|
10 |
sig
|
23524
|
11 |
val gen_qelim_conv: conv -> conv -> conv ->
|
23489
|
12 |
(cterm -> 'a -> 'a) -> 'a -> ('a -> cterm -> thm) ->
|
|
13 |
('a -> conv) -> ('a -> cterm -> thm) -> conv
|
23524
|
14 |
val standard_qelim_conv: (cterm list -> cterm -> thm) ->
|
23489
|
15 |
(cterm list -> conv) -> (cterm list -> cterm -> thm) -> cterm -> thm
|
23466
|
16 |
end;
|
|
17 |
|
23489
|
18 |
structure Qelim: QELIM =
|
23466
|
19 |
struct
|
|
20 |
|
|
21 |
open Conv;
|
|
22 |
|
23489
|
23 |
|
|
24 |
(* gen_qelim_conv *)
|
|
25 |
|
|
26 |
val all_not_ex = mk_meta_eq @{thm "all_not_ex"};
|
|
27 |
|
23524
|
28 |
fun gen_qelim_conv precv postcv simpex_conv ins env atcv ncv qcv =
|
23489
|
29 |
let
|
23466
|
30 |
fun conv env p =
|
23489
|
31 |
case (term_of p) of
|
|
32 |
Const(s,T)$_$_ => if domain_type T = HOLogic.boolT
|
23466
|
33 |
andalso s mem ["op &","op |","op -->","op ="]
|
|
34 |
then binop_conv (conv env) p else atcv env p
|
|
35 |
| Const("Not",_)$_ => arg_conv (conv env) p
|
23489
|
36 |
| Const("Ex",_)$Abs(s,_,_) =>
|
|
37 |
let
|
23466
|
38 |
val (e,p0) = Thm.dest_comb p
|
|
39 |
val (x,p') = Thm.dest_abs (SOME s) p0
|
|
40 |
val env' = ins x env
|
|
41 |
val th = Thm.abstract_rule s x ((conv env' then_conv ncv env') p')
|
|
42 |
|> Drule.arg_cong_rule e
|
|
43 |
val th' = simpex_conv (Thm.rhs_of th)
|
|
44 |
val (l,r) = Thm.dest_equals (cprop_of th')
|
|
45 |
in if is_refl th' then Thm.transitive th (qcv env (Thm.rhs_of th))
|
|
46 |
else Thm.transitive (Thm.transitive th th') (conv env r) end
|
23489
|
47 |
| Const("Ex",_)$ _ => (Thm.eta_long_conversion then_conv conv env) p
|
|
48 |
| Const("All",_)$_ =>
|
|
49 |
let
|
23466
|
50 |
val p = Thm.dest_arg p
|
|
51 |
val ([(_,T)],[]) = Thm.match (@{cpat "All"}, Thm.dest_fun p)
|
23489
|
52 |
val th = instantiate' [SOME T] [SOME p] all_not_ex
|
|
53 |
in transitive th (conv env (Thm.rhs_of th))
|
23466
|
54 |
end
|
|
55 |
| _ => atcv env p
|
|
56 |
in precv then_conv (conv env) then_conv postcv end
|
23489
|
57 |
|
|
58 |
|
|
59 |
(* standard_qelim_conv *)
|
23466
|
60 |
|
23489
|
61 |
val pcv = Simplifier.rewrite
|
|
62 |
(HOL_basic_ss addsimps (simp_thms @ ex_simps @ all_simps)
|
|
63 |
@ [@{thm "all_not_ex"}, not_all, ex_disj_distrib]);
|
23466
|
64 |
|
23524
|
65 |
fun standard_qelim_conv atcv ncv qcv p =
|
|
66 |
gen_qelim_conv pcv pcv pcv cons (Thm.add_cterm_frees p []) atcv ncv qcv p;
|
23466
|
67 |
|
|
68 |
end;
|