13876
|
1 |
(* Title: HOL/Integ/qelim.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Amine Chaieb and Tobias Nipkow, TU Muenchen
|
|
4 |
License: GPL (GNU GENERAL PUBLIC LICENSE)
|
|
5 |
|
|
6 |
File containing the implementation of the proof protocoling
|
|
7 |
and proof generation for multiple quantified formulae.
|
|
8 |
*)
|
|
9 |
|
|
10 |
signature QELIM =
|
|
11 |
sig
|
|
12 |
val proof_of_mlift_qelim: Sign.sg -> (term -> bool) ->
|
|
13 |
(string list -> term -> thm) -> (term -> thm) ->
|
|
14 |
(string list -> term -> thm) -> term -> thm
|
|
15 |
end;
|
|
16 |
|
|
17 |
structure Qelim : QELIM =
|
|
18 |
struct
|
|
19 |
open CooperDec;
|
|
20 |
open CooperProof;
|
|
21 |
|
|
22 |
(*-----------------------------------------------------------------*)
|
|
23 |
(*-----------------------------------------------------------------*)
|
|
24 |
(*-----------------------------------------------------------------*)
|
|
25 |
(*--- ---*)
|
|
26 |
(*--- ---*)
|
|
27 |
(*--- Protocoling part ---*)
|
|
28 |
(*--- ---*)
|
|
29 |
(*--- includes the protocolling datastructure ---*)
|
|
30 |
(*--- ---*)
|
|
31 |
(*--- and the protocolling fuctions ---*)
|
|
32 |
(*--- ---*)
|
|
33 |
(*--- ---*)
|
|
34 |
(*--- ---*)
|
|
35 |
(*-----------------------------------------------------------------*)
|
|
36 |
(*-----------------------------------------------------------------*)
|
|
37 |
(*-----------------------------------------------------------------*)
|
|
38 |
|
|
39 |
|
|
40 |
val cboolT = ctyp_of (sign_of HOL.thy) HOLogic.boolT;
|
|
41 |
|
|
42 |
(* List of the theorems to be used in the following*)
|
|
43 |
|
|
44 |
val qe_ex_conj = thm "qe_ex_conj";
|
|
45 |
val qe_ex_nconj = thm "qe_ex_nconj";
|
|
46 |
val qe_ALL = thm "qe_ALL";
|
|
47 |
|
|
48 |
|
|
49 |
(*Datatype declaration for the protocoling procedure.*)
|
|
50 |
|
|
51 |
|
|
52 |
datatype QeLog = AFN of term*(string list)
|
|
53 |
|QFN of term*(string list)
|
|
54 |
|ExConj of term*QeLog
|
|
55 |
|ExDisj of (string*typ*term)*term*QeLog*QeLog
|
|
56 |
|QeConst of string*QeLog*QeLog
|
|
57 |
|QeNot of QeLog
|
|
58 |
|QeAll of QeLog
|
|
59 |
|Lift_Qelim of term*QeLog
|
|
60 |
|QeUnk of term;
|
|
61 |
|
|
62 |
datatype mQeLog = mQeProof of (string list)*mQeLog
|
|
63 |
|mAFN of term
|
|
64 |
|mNFN of mQeLog
|
|
65 |
|mQeConst of string*mQeLog*mQeLog
|
|
66 |
|mQeNot of mQeLog
|
|
67 |
|mQelim of term*(string list)*mQeLog
|
|
68 |
|mQeAll of mQeLog
|
|
69 |
|mQefm of term;
|
|
70 |
|
|
71 |
(* This is the protokoling my function for the quantifier elimination*)
|
|
72 |
fun mlift_qelim_wp isat vars =
|
|
73 |
let fun mqelift_wp vars fm = if (isat fm) then mAFN(fm)
|
|
74 |
else
|
|
75 |
(case fm of
|
|
76 |
( Const ("Not",_) $ p) => mQeNot(mqelift_wp vars p)
|
|
77 |
|( Const ("op &",_) $ p $q) => mQeConst("CJ", mqelift_wp vars p,mqelift_wp vars q)
|
|
78 |
|
|
79 |
|( Const ("op |",_) $ p $q) => mQeConst("DJ", mqelift_wp vars p,mqelift_wp vars q)
|
|
80 |
|
|
81 |
|( Const ("op -->",_) $ p $q) => mQeConst("IM", mqelift_wp vars p,mqelift_wp vars q)
|
|
82 |
|
|
83 |
|( Const ("op =",Type ("fun",[Type ("bool", []),_])) $ p $q) =>mQeConst("EQ", mqelift_wp vars p,mqelift_wp vars q)
|
|
84 |
|
|
85 |
|
|
86 |
|( Const ("All",QT) $ Abs(x,T,p)) =>mQeAll (mqelift_wp vars (Const("Ex",QT) $ Abs(x,T,(HOLogic.Not $ p))))
|
|
87 |
|
|
88 |
|(Const ("Ex",_) $ Abs (x,T,p)) =>
|
|
89 |
let val (x1,p1) = variant_abs (x,T,p)
|
|
90 |
val prt = mqelift_wp (x1::vars) p1
|
|
91 |
in mQelim(Free(x1,T),vars,mNFN(prt))
|
|
92 |
end
|
|
93 |
| _ => mQefm(fm)
|
|
94 |
)
|
|
95 |
|
|
96 |
in (fn fm => mQeProof(vars,mNFN(mqelift_wp vars fm )))
|
|
97 |
end;
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
(*-----------------------------------------------------------------*)
|
|
103 |
(*-----------------------------------------------------------------*)
|
|
104 |
(*-----------------------------------------------------------------*)
|
|
105 |
(*--- ---*)
|
|
106 |
(*--- ---*)
|
|
107 |
(*--- Interpretation and Proofgeneration Part ---*)
|
|
108 |
(*--- ---*)
|
|
109 |
(*--- Protocole interpretation functions ---*)
|
|
110 |
(*--- ---*)
|
|
111 |
(*--- and proofgeneration functions ---*)
|
|
112 |
(*--- ---*)
|
|
113 |
(*--- ---*)
|
|
114 |
(*--- ---*)
|
|
115 |
(*--- ---*)
|
|
116 |
(*-----------------------------------------------------------------*)
|
|
117 |
(*-----------------------------------------------------------------*)
|
|
118 |
(*-----------------------------------------------------------------*)
|
|
119 |
|
|
120 |
(*-----------------------------------------------------------------*)
|
|
121 |
(*-----------------------------------------------------------------*)
|
|
122 |
(*function that interpretates the protokol generated by the _wp function*)
|
|
123 |
|
|
124 |
|
|
125 |
(* proof_of_lift_qelim interpretates a protokol for the quantifier elimination one some quantified formula. It uses the functions afnp nfnp and qfnp as proof functions to generate a prove for the hole quantifier elimination.*)
|
|
126 |
(* afnp : must retun a proof for the transformations on the atomic formalae*)
|
|
127 |
(* nfnp : must return a proof for the post one-quatifiers elimination process*)
|
|
128 |
(* qfnp mus return a proof for the one quantifier elimination (existential) *)
|
|
129 |
(* All these function are independent of the theory on whitch we are trying to prove quantifier elimination*)
|
|
130 |
(* But the following invariants mus be respected : *)
|
|
131 |
(* afnp : term -> string list -> thm*)
|
|
132 |
(* nfnp : term -> thm*)
|
|
133 |
(* qfnp : term -> string list -> thm*)
|
|
134 |
(*For all theorms generated by these function must hold :*)
|
|
135 |
(* All of them are logical equivalences.*)
|
|
136 |
(* on left side of the equivalence must appear the term exactely as ist was given as a parameter (or eventually modulo Gamma, where Gamma are the rules whitch are allowed to be used during unification ex. beta reduction.....)*)
|
|
137 |
(* qfnp must take as an argument for the term an existential quantified formula*)
|
|
138 |
(*-----------------------------------------------------------------*)
|
|
139 |
(*-----------------------------------------------------------------*)
|
|
140 |
|
|
141 |
fun proof_of_mlift_qelim sg isat afnp nfnp qfnp =
|
|
142 |
let fun h_proof_of_mlift_qelim isat afnp nfnp qfnp prtkl vrl =
|
|
143 |
(case prtkl of
|
|
144 |
mAFN (fm) => afnp vrl fm
|
|
145 |
|mNFN (prt) => let val th1 = h_proof_of_mlift_qelim isat afnp nfnp qfnp prt vrl
|
|
146 |
val th2 = nfnp (snd (qe_get_terms th1))
|
|
147 |
in [th1,th2] MRS trans
|
|
148 |
end
|
|
149 |
|mQeConst (s,pr1,pr2) =>
|
|
150 |
let val th1 = h_proof_of_mlift_qelim isat afnp nfnp qfnp pr1 vrl
|
|
151 |
val th2 = h_proof_of_mlift_qelim isat afnp nfnp qfnp pr2 vrl
|
|
152 |
in (case s of
|
|
153 |
"CJ" => [th1,th2] MRS (qe_conjI)
|
|
154 |
|"DJ" => [th1,th2] MRS (qe_disjI)
|
|
155 |
|"IM" => [th1,th2] MRS (qe_impI)
|
|
156 |
|"EQ" => [th1,th2] MRS (qe_eqI)
|
|
157 |
)
|
|
158 |
end
|
|
159 |
|mQeNot (pr) =>(h_proof_of_mlift_qelim isat afnp nfnp qfnp pr vrl ) RS (qe_Not)
|
|
160 |
|mQeAll(pr) => (h_proof_of_mlift_qelim isat afnp nfnp qfnp pr vrl ) RS (qe_ALL)
|
|
161 |
|mQelim (x as (Free(xn,xT)),vl,pr) =>
|
|
162 |
let val th_1 = h_proof_of_mlift_qelim isat afnp nfnp qfnp pr vl
|
|
163 |
val mQeProof(l2,pr2) = mlift_qelim_wp isat (xn::vrl) (snd(qe_get_terms th_1))
|
|
164 |
val th_2 = [th_1,(h_proof_of_mlift_qelim isat afnp nfnp qfnp pr2 l2)] MRS trans
|
|
165 |
val th1 = (forall_intr (cterm_of sg x) th_2) COMP (qe_exI)
|
|
166 |
val th2 = qfnp vl (snd (qe_get_terms th1))
|
|
167 |
in [th1,th2] MRS trans
|
|
168 |
end
|
|
169 |
|mQefm (fm) => instantiate' [Some cboolT] [Some (cterm_of sg fm)] refl
|
|
170 |
)
|
|
171 |
in (fn fm => let val mQeProof(vars,prt) = (mlift_qelim_wp isat (fv fm) fm)
|
|
172 |
in (h_proof_of_mlift_qelim isat afnp nfnp qfnp prt vars)
|
|
173 |
end)
|
|
174 |
end;
|
|
175 |
|
|
176 |
end;
|