66 sig |
66 sig |
67 val prove_one_point_all_tac: tactic |
67 val prove_one_point_all_tac: tactic |
68 val prove_one_point_ex_tac: tactic |
68 val prove_one_point_ex_tac: tactic |
69 val rearrange_all: Proof.context -> cterm -> thm option |
69 val rearrange_all: Proof.context -> cterm -> thm option |
70 val rearrange_ex: Proof.context -> cterm -> thm option |
70 val rearrange_ex: Proof.context -> cterm -> thm option |
71 val rearrange_ball: tactic -> Proof.context -> cterm -> thm option |
71 val rearrange_ball: (Proof.context -> tactic) -> Proof.context -> cterm -> thm option |
72 val rearrange_bex: tactic -> Proof.context -> cterm -> thm option |
72 val rearrange_bex: (Proof.context -> tactic) -> Proof.context -> cterm -> thm option |
73 val rearrange_Collect: tactic -> Proof.context -> cterm -> thm option |
73 val rearrange_Collect: (Proof.context -> tactic) -> Proof.context -> cterm -> thm option |
74 end; |
74 end; |
75 |
75 |
76 functor Quantifier1(Data: QUANTIFIER1_DATA): QUANTIFIER1 = |
76 functor Quantifier1(Data: QUANTIFIER1_DATA): QUANTIFIER1 = |
77 struct |
77 struct |
78 |
78 |
118 fun exqu xs ((qC as Const (qa, _)) $ Abs (x, T, Q)) = |
118 fun exqu xs ((qC as Const (qa, _)) $ Abs (x, T, Q)) = |
119 if qa = q then exqu ((qC, x, T) :: xs) Q else NONE |
119 if qa = q then exqu ((qC, x, T) :: xs) Q else NONE |
120 | exqu xs P = extract (null xs) xs P |
120 | exqu xs P = extract (null xs) xs P |
121 in exqu [] end; |
121 in exqu [] end; |
122 |
122 |
123 fun prove_conv tac ctxt tu = |
123 fun prove_conv ctxt tu tac = |
124 let |
124 let |
125 val (goal, ctxt') = |
125 val (goal, ctxt') = |
126 yield_singleton (Variable.import_terms true) (Logic.mk_equals tu) ctxt; |
126 yield_singleton (Variable.import_terms true) (Logic.mk_equals tu) ctxt; |
127 val thm = |
127 val thm = |
128 Goal.prove ctxt' [] [] goal (K (rtac Data.iff_reflection 1 THEN tac)); |
128 Goal.prove ctxt' [] [] goal |
|
129 (fn {context = ctxt'', ...} => rtac Data.iff_reflection 1 THEN tac ctxt''); |
129 in singleton (Variable.export ctxt' ctxt) thm end; |
130 in singleton (Variable.export ctxt' ctxt) thm end; |
130 |
131 |
131 fun qcomm_tac qcomm qI i = REPEAT_DETERM (rtac qcomm i THEN rtac qI i); |
132 fun qcomm_tac qcomm qI i = REPEAT_DETERM (rtac qcomm i THEN rtac qI i); |
132 |
133 |
133 (* Proves (? x0..xn. ... & x0 = t & ...) = (? x1..xn x0. x0 = t & ... & ...) |
134 (* Proves (? x0..xn. ... & x0 = t & ...) = (? x1..xn x0. x0 = t & ... & ...) |
176 F as (all as Const (q, _)) $ Abs (x, T, P) => |
177 F as (all as Const (q, _)) $ Abs (x, T, P) => |
177 (case extract_quant extract_imp q P of |
178 (case extract_quant extract_imp q P of |
178 NONE => NONE |
179 NONE => NONE |
179 | SOME (xs, eq, Q) => |
180 | SOME (xs, eq, Q) => |
180 let val R = quantify all x T xs (Data.imp $ eq $ Q) |
181 let val R = quantify all x T xs (Data.imp $ eq $ Q) |
181 in SOME (prove_conv prove_one_point_all_tac ctxt (F, R)) end) |
182 in SOME (prove_conv ctxt (F, R) (K prove_one_point_all_tac)) end) |
182 | _ => NONE); |
183 | _ => NONE); |
183 |
184 |
184 fun rearrange_ball tac ctxt ct = |
185 fun rearrange_ball tac ctxt ct = |
185 (case term_of ct of |
186 (case term_of ct of |
186 F as Ball $ A $ Abs (x, T, P) => |
187 F as Ball $ A $ Abs (x, T, P) => |
188 NONE => NONE |
189 NONE => NONE |
189 | SOME (xs, eq, Q) => |
190 | SOME (xs, eq, Q) => |
190 if not (null xs) then NONE |
191 if not (null xs) then NONE |
191 else |
192 else |
192 let val R = Data.imp $ eq $ Q |
193 let val R = Data.imp $ eq $ Q |
193 in SOME (prove_conv tac ctxt (F, Ball $ A $ Abs (x, T, R))) end) |
194 in SOME (prove_conv ctxt (F, Ball $ A $ Abs (x, T, R)) tac) end) |
194 | _ => NONE); |
195 | _ => NONE); |
195 |
196 |
196 fun rearrange_ex ctxt ct = |
197 fun rearrange_ex ctxt ct = |
197 (case term_of ct of |
198 (case term_of ct of |
198 F as (ex as Const (q, _)) $ Abs (x, T, P) => |
199 F as (ex as Const (q, _)) $ Abs (x, T, P) => |
199 (case extract_quant extract_conj q P of |
200 (case extract_quant extract_conj q P of |
200 NONE => NONE |
201 NONE => NONE |
201 | SOME (xs, eq, Q) => |
202 | SOME (xs, eq, Q) => |
202 let val R = quantify ex x T xs (Data.conj $ eq $ Q) |
203 let val R = quantify ex x T xs (Data.conj $ eq $ Q) |
203 in SOME (prove_conv prove_one_point_ex_tac ctxt (F, R)) end) |
204 in SOME (prove_conv ctxt (F, R) (K prove_one_point_ex_tac)) end) |
204 | _ => NONE); |
205 | _ => NONE); |
205 |
206 |
206 fun rearrange_bex tac ctxt ct = |
207 fun rearrange_bex tac ctxt ct = |
207 (case term_of ct of |
208 (case term_of ct of |
208 F as Bex $ A $ Abs (x, T, P) => |
209 F as Bex $ A $ Abs (x, T, P) => |
209 (case extract_conj true [] P of |
210 (case extract_conj true [] P of |
210 NONE => NONE |
211 NONE => NONE |
211 | SOME (xs, eq, Q) => |
212 | SOME (xs, eq, Q) => |
212 if not (null xs) then NONE |
213 if not (null xs) then NONE |
213 else SOME (prove_conv tac ctxt (F, Bex $ A $ Abs (x, T, Data.conj $ eq $ Q)))) |
214 else SOME (prove_conv ctxt (F, Bex $ A $ Abs (x, T, Data.conj $ eq $ Q)) tac)) |
214 | _ => NONE); |
215 | _ => NONE); |
215 |
216 |
216 fun rearrange_Collect tac ctxt ct = |
217 fun rearrange_Collect tac ctxt ct = |
217 (case term_of ct of |
218 (case term_of ct of |
218 F as Collect $ Abs (x, T, P) => |
219 F as Collect $ Abs (x, T, P) => |
219 (case extract_conj true [] P of |
220 (case extract_conj true [] P of |
220 NONE => NONE |
221 NONE => NONE |
221 | SOME (_, eq, Q) => |
222 | SOME (_, eq, Q) => |
222 let val R = Collect $ Abs (x, T, Data.conj $ eq $ Q) |
223 let val R = Collect $ Abs (x, T, Data.conj $ eq $ Q) |
223 in SOME (prove_conv tac ctxt (F, R)) end) |
224 in SOME (prove_conv ctxt (F, R) tac) end) |
224 | _ => NONE); |
225 | _ => NONE); |
225 |
226 |
226 end; |
227 end; |
227 |
228 |