328 in (([], prems, stmt, NONE), goal_ctxt) end |
328 in (([], prems, stmt, NONE), goal_ctxt) end |
329 | Element.Obtains obtains => |
329 | Element.Obtains obtains => |
330 let |
330 let |
331 val constraints = obtains |> map (fn (_, (vars, _)) => |
331 val constraints = obtains |> map (fn (_, (vars, _)) => |
332 Element.Constrains |
332 Element.Constrains |
333 (vars |> map_filter (fn (x, SOME T) => SOME (Variable.check_name x, T) | _ => NONE))); |
333 (vars |> map_filter (fn (x, SOME T, _) => SOME (Variable.check_name x, T) | _ => NONE))); |
334 |
334 |
335 val raw_propp = obtains |> map (fn (_, (_, props)) => map (rpair []) props); |
335 val raw_propp = obtains |> map (fn (_, (_, props)) => map (rpair []) props); |
336 val (propp, elems_ctxt) = prep_stmt (elems @ constraints) raw_propp ctxt; |
336 val (propp, elems_ctxt) = prep_stmt (elems @ constraints) raw_propp ctxt; |
337 |
337 |
338 val thesis = Object_Logic.fixed_judgment ctxt Auto_Bind.thesisN; |
338 val thesis = Object_Logic.fixed_judgment ctxt Auto_Bind.thesisN; |
339 |
339 |
340 fun assume_case ((name, (vars, _)), asms) ctxt' = |
340 fun assume_case ((name, (vars, _)), asms) ctxt' = |
341 let |
341 let |
342 val bs = map fst vars; |
342 val bs = map (fn (b, _, _) => b) vars; |
343 val xs = map Variable.check_name bs; |
343 val xs = map Variable.check_name bs; |
344 val props = map fst asms; |
344 val props = map fst asms; |
345 val (params, _) = ctxt' |
345 val (params, _) = ctxt' |
346 |> fold Variable.declare_term props |
346 |> fold Variable.declare_term props |
347 |> fold_map Proof_Context.inferred_param xs |
347 |> fold_map Proof_Context.inferred_param xs |
362 |
362 |
363 val (facts, goal_ctxt) = elems_ctxt |
363 val (facts, goal_ctxt) = elems_ctxt |
364 |> (snd o Proof_Context.add_fixes [(Binding.name Auto_Bind.thesisN, NONE, NoSyn)]) |
364 |> (snd o Proof_Context.add_fixes [(Binding.name Auto_Bind.thesisN, NONE, NoSyn)]) |
365 |> fold_map assume_case (obtains ~~ propp) |
365 |> fold_map assume_case (obtains ~~ propp) |
366 |-> (fn ths => |
366 |-> (fn ths => |
367 Proof_Context.note_thmss "" [((Binding.name Obtain.thatN, []), [(ths, [])])] #> |
367 Proof_Context.note_thmss "" [((Binding.name Auto_Bind.thatN, []), [(ths, [])])] #> |
368 #2 #> pair ths); |
368 #2 #> pair ths); |
369 in ((more_atts, prems, stmt, SOME facts), goal_ctxt) end); |
369 in ((more_atts, prems, stmt, SOME facts), goal_ctxt) end); |
370 |
370 |
371 fun gen_theorem schematic bundle_includes prep_att prep_stmt |
371 fun gen_theorem schematic bundle_includes prep_att prep_stmt |
372 kind before_qed after_qed (name, raw_atts) raw_includes raw_elems raw_concl int lthy = |
372 kind before_qed after_qed (name, raw_atts) raw_includes raw_elems raw_concl int lthy = |