11 (binding * typ option * mixfix) list -> string list -> term |
11 (binding * typ option * mixfix) list -> string list -> term |
12 val read_obtains: Proof.context -> term -> Element.obtains -> (binding * term) list |
12 val read_obtains: Proof.context -> term -> Element.obtains -> (binding * term) list |
13 val cert_obtains: Proof.context -> term -> Element.obtains_i -> (binding * term) list |
13 val cert_obtains: Proof.context -> term -> Element.obtains_i -> (binding * term) list |
14 val consider: Element.obtains_i -> bool -> Proof.state -> Proof.state |
14 val consider: Element.obtains_i -> bool -> Proof.state -> Proof.state |
15 val consider_cmd: Element.obtains -> bool -> Proof.state -> Proof.state |
15 val consider_cmd: Element.obtains -> bool -> Proof.state -> Proof.state |
16 val obtain: string -> (binding * typ option * mixfix) list -> |
16 val obtain: binding -> (binding * typ option * mixfix) list -> |
17 (Thm.binding * (term * term list) list) list -> bool -> Proof.state -> Proof.state |
17 (Thm.binding * (term * term list) list) list -> bool -> Proof.state -> Proof.state |
18 val obtain_cmd: string -> (binding * string option * mixfix) list -> |
18 val obtain_cmd: binding -> (binding * string option * mixfix) list -> |
19 (Attrib.binding * (string * string list) list) list -> bool -> Proof.state -> Proof.state |
19 (Attrib.binding * (string * string list) list) list -> bool -> Proof.state -> Proof.state |
20 val result: (Proof.context -> tactic) -> thm list -> Proof.context -> |
20 val result: (Proof.context -> tactic) -> thm list -> Proof.context -> |
21 ((string * cterm) list * thm list) * Proof.context |
21 ((string * cterm) list * thm list) * Proof.context |
22 val guess: (binding * typ option * mixfix) list -> bool -> Proof.state -> Proof.state |
22 val guess: (binding * typ option * mixfix) list -> bool -> Proof.state -> Proof.state |
23 val guess_cmd: (binding * string option * mixfix) list -> bool -> Proof.state -> Proof.state |
23 val guess_cmd: (binding * string option * mixfix) list -> bool -> Proof.state -> Proof.state |
148 local |
148 local |
149 |
149 |
150 fun gen_consider prep_obtains raw_obtains int state = |
150 fun gen_consider prep_obtains raw_obtains int state = |
151 let |
151 let |
152 val _ = Proof.assert_forward_or_chain state; |
152 val _ = Proof.assert_forward_or_chain state; |
153 |
|
154 val ctxt = Proof.context_of state; |
153 val ctxt = Proof.context_of state; |
|
154 |
155 val ((_, thesis), thesis_ctxt) = obtain_thesis ctxt; |
155 val ((_, thesis), thesis_ctxt) = obtain_thesis ctxt; |
156 val obtains = prep_obtains thesis_ctxt thesis raw_obtains; |
156 val obtains = prep_obtains thesis_ctxt thesis raw_obtains; |
157 in |
157 in |
158 state |
158 state |
159 |> Proof.have NONE (K I) |
159 |> Proof.have NONE (K I) |
174 |
174 |
175 |
175 |
176 (** obtain: augmented context based on generalized existence rule **) |
176 (** obtain: augmented context based on generalized existence rule **) |
177 |
177 |
178 (* |
178 (* |
179 <chain_facts> |
179 obtain (a) x where "A x" <proof> == |
180 obtain x where "A x" <proof> == |
180 |
181 |
181 have thesis if a [intro?]: "!!x. A x ==> thesis" for thesis |
182 have "!!thesis. (!!x. A x ==> thesis) ==> thesis" |
182 apply (insert that) |
183 proof succeed |
183 <proof> |
184 fix thesis |
|
185 assume that [intro?]: "!!x. A x ==> thesis" |
|
186 <chain_facts> |
|
187 show thesis |
|
188 apply (insert that) |
|
189 <proof> |
|
190 qed |
|
191 fix x assm <<obtain_export>> "A x" |
184 fix x assm <<obtain_export>> "A x" |
192 *) |
185 *) |
193 |
186 |
194 local |
187 local |
195 |
188 |
196 fun gen_obtain prep_att prep_var prep_propp |
189 fun gen_obtain prep_att prep_var prep_propp |
197 name raw_vars raw_asms int state = |
190 that_binding raw_vars raw_asms int state = |
198 let |
191 let |
199 val _ = Proof.assert_forward_or_chain state; |
192 val _ = Proof.assert_forward_or_chain state; |
200 val ctxt = Proof.context_of state; |
193 val ctxt = Proof.context_of state; |
201 val chain_facts = if can Proof.assert_chain state then Proof.the_facts state else []; |
|
202 |
194 |
203 (*vars*) |
195 (*vars*) |
204 val ((thesis_var, thesis), thesis_ctxt) = obtain_thesis ctxt; |
196 val ((_, thesis), thesis_ctxt) = obtain_thesis ctxt; |
205 val ((xs', vars), fix_ctxt) = thesis_ctxt |
197 val ((xs', vars), fix_ctxt) = thesis_ctxt |
206 |> fold_map prep_var raw_vars |
198 |> fold_map prep_var raw_vars |
207 |-> (fn vars => Proof_Context.add_fixes vars ##>> pair vars); |
199 |-> (fn vars => Proof_Context.add_fixes vars ##>> pair vars); |
208 val xs = map (Variable.check_name o #1) vars; |
200 val xs = map (Variable.check_name o #1) vars; |
209 |
201 |
224 val binds' = (map o apsnd) (fold_rev Term.dependent_lambda_name (xs ~~ params)) binds; |
216 val binds' = (map o apsnd) (fold_rev Term.dependent_lambda_name (xs ~~ params)) binds; |
225 |
217 |
226 val _ = Variable.warn_extra_tfrees fix_ctxt params_ctxt; |
218 val _ = Variable.warn_extra_tfrees fix_ctxt params_ctxt; |
227 |
219 |
228 (*statements*) |
220 (*statements*) |
229 val that_name = if name = "" then Auto_Bind.thatN else name; |
|
230 val that_prop = |
221 val that_prop = |
231 Logic.list_rename_params xs |
222 Logic.list_rename_params xs |
232 (fold_rev Logic.all params (Logic.list_implies (props, thesis))); |
223 (fold_rev Logic.all params (Logic.list_implies (props, thesis))); |
233 val obtain_prop = |
224 |
234 Logic.list_rename_params [Auto_Bind.thesisN] |
225 fun after_qed (result_ctxt, results) state' = |
235 (Logic.all (Free thesis_var) (Logic.mk_implies (that_prop, thesis))); |
226 let val [rule] = Proof_Context.export result_ctxt (Proof.context_of state') (flat results) in |
236 |
227 state' |
237 fun after_qed _ = |
228 |> Proof.fix vars |
238 Proof.local_qed (NONE, false) |
229 |> Proof.map_context declare_asms |
239 #> `Proof.the_fact #-> (fn rule => |
230 |> Proof.assm (obtain_export params_ctxt rule cparams) asms |
240 Proof.fix vars |
231 end; |
241 #> Proof.map_context declare_asms |
|
242 #> Proof.assm (obtain_export params_ctxt rule cparams) asms); |
|
243 in |
232 in |
244 state |
233 state |
245 |> Proof.enter_forward |
234 |> Proof.have NONE after_qed |
246 |> Proof.have NONE (K I) [] [] [(Thm.empty_binding, [(obtain_prop, [])])] int |
235 [(Binding.name Auto_Bind.thesisN, NONE, NoSyn)] |
|
236 [((that_binding, [Context_Rules.intro_query NONE]), [(that_prop, [])])] |
|
237 [(Thm.empty_binding, [(thesis, [])])] int |
|
238 |> (fn state' => state' |
|
239 |> Proof.refine_insert (Assumption.local_prems_of (Proof.context_of state') ctxt)) |
247 |> Proof.map_context (fold Variable.bind_term binds') |
240 |> Proof.map_context (fold Variable.bind_term binds') |
248 |> Proof.proof (SOME Method.succeed_text) |> Seq.hd |
|
249 |> Proof.fix [(Binding.name Auto_Bind.thesisN, NONE, NoSyn)] |
|
250 |> Proof.assume |
|
251 [((Binding.name that_name, [Context_Rules.intro_query NONE]), [(that_prop, [])])] |
|
252 |> `Proof.the_facts |
|
253 ||> Proof.chain_facts chain_facts |
|
254 ||> Proof.show NONE after_qed [] [] [(Thm.empty_binding, [(thesis, [])])] false |
|
255 |-> Proof.refine_insert |
|
256 end; |
241 end; |
257 |
242 |
258 in |
243 in |
259 |
244 |
260 val obtain = gen_obtain (K I) Proof_Context.cert_var Proof_Context.cert_propp; |
245 val obtain = gen_obtain (K I) Proof_Context.cert_var Proof_Context.cert_propp; |