equal
deleted
inserted
replaced
10 obtain x where "P x" <proof> == |
10 obtain x where "P x" <proof> == |
11 |
11 |
12 { |
12 { |
13 fix thesis |
13 fix thesis |
14 assume that: "!!x. P x ==> thesis" |
14 assume that: "!!x. P x ==> thesis" |
15 <chain_facts> have thesis <proof> |
15 <chain_facts> have thesis <proof (insert that)> |
16 } |
16 } |
17 fix x assm(obtained) "P x" |
17 fix x assm (obtained) "P x" |
18 |
18 |
19 *) |
19 *) |
20 |
|
21 signature OBTAIN_DATA = |
|
22 sig |
|
23 val atomic_thesis: string -> term |
|
24 val that_atts: Proof.context attribute list |
|
25 end; |
|
26 |
20 |
27 signature OBTAIN = |
21 signature OBTAIN = |
28 sig |
22 sig |
29 val obtain: ((string list * string option) * Comment.text) list |
23 val obtain: ((string list * string option) * Comment.text) list |
30 * ((string * Args.src list * (string * (string list * string list)) list) |
24 * ((string * Args.src list * (string * (string list * string list)) list) |
32 val obtain_i: ((string list * typ option) * Comment.text) list |
26 val obtain_i: ((string list * typ option) * Comment.text) list |
33 * ((string * Proof.context attribute list * (term * (term list * term list)) list) |
27 * ((string * Proof.context attribute list * (term * (term list * term list)) list) |
34 * Comment.text) list -> ProofHistory.T -> ProofHistory.T |
28 * Comment.text) list -> ProofHistory.T -> ProofHistory.T |
35 end; |
29 end; |
36 |
30 |
37 functor ObtainFun(Data: OBTAIN_DATA): OBTAIN = |
31 structure Obtain: OBTAIN = |
38 struct |
32 struct |
39 |
33 |
40 |
34 |
41 (** disch_obtained **) |
35 (** disch_obtained **) |
42 |
36 |
56 in |
50 in |
57 if not (null bads) then |
51 if not (null bads) then |
58 raise Proof.STATE ("Conclusion contains obtained parameters: " ^ |
52 raise Proof.STATE ("Conclusion contains obtained parameters: " ^ |
59 space_implode " " (map (Sign.string_of_term sign) bads), state) |
53 space_implode " " (map (Sign.string_of_term sign) bads), state) |
60 else if not (AutoBind.is_judgment (Logic.strip_assums_concl prop)) then |
54 else if not (AutoBind.is_judgment (Logic.strip_assums_concl prop)) then |
61 raise Proof.STATE ("Conclusion is not an object-logic judgment", state) |
55 raise Proof.STATE ("Conclusions of 'obtain' context must be object-logic judgments", state) |
62 else (Tactic.rtac thm' THEN' RANGE elim_tacs) 1 rule |
56 else (Tactic.rtac thm' THEN' RANGE elim_tacs) 1 rule |
63 end; |
57 end; |
64 |
58 |
65 |
59 |
66 |
60 |
100 (case ProofContext.find_free t x of Some (Free a) => Some a | _ => None); |
94 (case ProofContext.find_free t x of Some (Free a) => Some a | _ => None); |
101 fun occs_var x = Library.get_first (find_free x) asm_props; |
95 fun occs_var x = Library.get_first (find_free x) asm_props; |
102 val xs' = mapfilter occs_var xs; |
96 val xs' = mapfilter occs_var xs; |
103 val parms = map (bind_skolem o Free) xs'; |
97 val parms = map (bind_skolem o Free) xs'; |
104 |
98 |
105 val bound_thesis = bind_skolem (Data.atomic_thesis thesisN); |
99 val bound_thesis = bind_skolem (AutoBind.atomic_judgment (Proof.theory_of state) thesisN); |
106 val that_prop = Term.list_all_free (xs', Logic.list_implies (asm_props, bound_thesis)); |
100 val that_prop = Term.list_all_free (xs', Logic.list_implies (asm_props, bound_thesis)); |
107 |
101 |
108 fun export_obtained rule = |
102 fun export_obtained rule = |
109 (disch_obtained state parms rule, fn _ => fn _ => []); |
103 (disch_obtained state parms rule, fn _ => fn _ => []); |
110 |
104 |
116 in |
110 in |
117 state |
111 state |
118 |> Proof.enter_forward |
112 |> Proof.enter_forward |
119 |> Proof.begin_block |
113 |> Proof.begin_block |
120 |> Proof.fix_i [([thesisN], None)] |
114 |> Proof.fix_i [([thesisN], None)] |
121 |> Proof.assume_i [(thatN, Data.that_atts, [(that_prop, ([], []))])] |
115 |> Proof.assume_i [(thatN, [Method.intro_local], [(that_prop, ([], []))])] |
122 |> Proof.from_facts chain_facts |
116 |> (fn state' => |
123 |> Proof.have_i after_qed "" [] (bound_thesis, ([], [])) |
117 state' |
|
118 |> Proof.from_facts chain_facts |
|
119 |> Proof.have_i after_qed "" [] (bound_thesis, ([], [])) |
|
120 |> Method.refine (Method.Basic (K (Method.insert (Proof.the_facts state'))))) |
124 end; |
121 end; |
125 |
122 |
126 |
123 |
127 val obtain = ProofHistory.apply o |
124 val obtain = ProofHistory.applys o |
128 (gen_obtain ProofContext.read_vars ProofContext.read_propp Attrib.local_attribute); |
125 (gen_obtain ProofContext.read_vars ProofContext.read_propp Attrib.local_attribute); |
129 |
126 |
130 val obtain_i = ProofHistory.apply o |
127 val obtain_i = ProofHistory.applys o |
131 (gen_obtain ProofContext.cert_vars ProofContext.cert_propp (K I)); |
128 (gen_obtain ProofContext.cert_vars ProofContext.cert_propp (K I)); |
132 |
129 |
133 |
130 |
134 |
131 |
135 (** outer syntax **) |
132 (** outer syntax **) |