1 (* Title: HOL/Tools/Qelim/qelim.ML
2 Author: Amine Chaieb, TU Muenchen
4 Generic quantifier elimination conversions for HOL formulae.
9 val gen_qelim_conv: conv -> conv -> conv -> (cterm -> 'a -> 'a) -> 'a
10 -> ('a -> conv) -> ('a -> conv) -> ('a -> conv) -> conv
11 val standard_qelim_conv: (cterm list -> conv) -> (cterm list -> conv)
12 -> (cterm list -> conv) -> conv
15 structure Qelim: QELIM =
20 val all_not_ex = mk_meta_eq @{thm "all_not_ex"};
22 fun gen_qelim_conv precv postcv simpex_conv ins env atcv ncv qcv =
27 if domain_type T = HOLogic.boolT
28 andalso member (op =) [@{const_name "op &"}, @{const_name "op |"},
29 @{const_name "op -->"}, @{const_name "op ="}] s
30 then binop_conv (conv env) p
32 | Const(@{const_name Not},_)$_ => arg_conv (conv env) p
33 | Const(@{const_name Ex},_)$Abs(s,_,_) =>
35 val (e,p0) = Thm.dest_comb p
36 val (x,p') = Thm.dest_abs (SOME s) p0
38 val th = Thm.abstract_rule s x ((conv env' then_conv ncv env') p')
39 |> Drule.arg_cong_rule e
40 val th' = simpex_conv (Thm.rhs_of th)
41 val (l,r) = Thm.dest_equals (cprop_of th')
42 in if Thm.is_reflexive th' then Thm.transitive th (qcv env (Thm.rhs_of th))
43 else Thm.transitive (Thm.transitive th th') (conv env r) end
44 | Const(@{const_name Ex},_)$ _ => (Thm.eta_long_conversion then_conv conv env) p
45 | Const(@{const_name All},_)$_ =>
47 val p = Thm.dest_arg p
48 val ([(_,T)],[]) = Thm.match (@{cpat "All"}, Thm.dest_fun p)
49 val th = instantiate' [SOME T] [SOME p] all_not_ex
50 in Thm.transitive th (conv env (Thm.rhs_of th))
53 in precv then_conv (conv env) then_conv postcv end
55 (* Instantiation of some parameter for most common cases *)
60 (HOL_basic_ss addsimps (@{thms simp_thms} @ @{thms ex_simps} @ @{thms all_simps} @
61 [@{thm all_not_ex}, not_all, @{thm ex_disj_distrib}]));
63 in fun standard_qelim_conv atcv ncv qcv p =
64 gen_qelim_conv pcv pcv pcv cons (Thm.add_cterm_frees p []) atcv ncv qcv p