19 val global_attribute: theory -> Args.src -> theory attribute |
19 val global_attribute: theory -> Args.src -> theory attribute |
20 val local_attribute: theory -> Args.src -> Proof.context attribute |
20 val local_attribute: theory -> Args.src -> Proof.context attribute |
21 val local_attribute': Proof.context -> Args.src -> Proof.context attribute |
21 val local_attribute': Proof.context -> Args.src -> Proof.context attribute |
22 val add_attributes: (bstring * ((Args.src -> theory attribute) * |
22 val add_attributes: (bstring * ((Args.src -> theory attribute) * |
23 (Args.src -> Proof.context attribute)) * string) list -> theory -> theory |
23 (Args.src -> Proof.context attribute)) * string) list -> theory -> theory |
24 val global_thm: theory * Args.T list -> tthm * (theory * Args.T list) |
24 val global_thm: theory * Args.T list -> thm * (theory * Args.T list) |
25 val global_thms: theory * Args.T list -> tthm list * (theory * Args.T list) |
25 val global_thms: theory * Args.T list -> thm list * (theory * Args.T list) |
26 val global_thmss: theory * Args.T list -> tthm list * (theory * Args.T list) |
26 val global_thmss: theory * Args.T list -> thm list * (theory * Args.T list) |
27 val local_thm: Proof.context * Args.T list -> tthm * (Proof.context * Args.T list) |
27 val local_thm: Proof.context * Args.T list -> thm * (Proof.context * Args.T list) |
28 val local_thms: Proof.context * Args.T list -> tthm list * (Proof.context * Args.T list) |
28 val local_thms: Proof.context * Args.T list -> thm list * (Proof.context * Args.T list) |
29 val local_thmss: Proof.context * Args.T list -> tthm list * (Proof.context * Args.T list) |
29 val local_thmss: Proof.context * Args.T list -> thm list * (Proof.context * Args.T list) |
30 val syntax: ('a * Args.T list -> 'a attribute * ('a * Args.T list)) -> Args.src -> 'a attribute |
30 val syntax: ('a * Args.T list -> 'a attribute * ('a * Args.T list)) -> Args.src -> 'a attribute |
31 val no_args: 'a attribute -> Args.src -> 'a attribute |
31 val no_args: 'a attribute -> Args.src -> 'a attribute |
32 val setup: (theory -> theory) list |
32 val setup: (theory -> theory) list |
33 end; |
33 end; |
34 |
34 |
125 |
125 |
126 fun gen_thm get attrib app = |
126 fun gen_thm get attrib app = |
127 Scan.depend (fn st => Args.name -- Args.opt_attribs >> |
127 Scan.depend (fn st => Args.name -- Args.opt_attribs >> |
128 (fn (name, srcs) => app ((st, get st name), map (attrib st) srcs))); |
128 (fn (name, srcs) => app ((st, get st name), map (attrib st) srcs))); |
129 |
129 |
130 val global_thm = gen_thm PureThy.get_tthm global_attribute Attribute.apply; |
130 val global_thm = gen_thm PureThy.get_thm global_attribute Thm.apply_attributes; |
131 val global_thms = gen_thm PureThy.get_tthms global_attribute Attribute.applys; |
131 val global_thms = gen_thm PureThy.get_thms global_attribute Thm.applys_attributes; |
132 val global_thmss = Scan.repeat global_thms >> flat; |
132 val global_thmss = Scan.repeat global_thms >> flat; |
133 |
133 |
134 val local_thm = gen_thm ProofContext.get_tthm local_attribute' Attribute.apply; |
134 val local_thm = gen_thm ProofContext.get_thm local_attribute' Thm.apply_attributes; |
135 val local_thms = gen_thm ProofContext.get_tthms local_attribute' Attribute.applys; |
135 val local_thms = gen_thm ProofContext.get_thms local_attribute' Thm.applys_attributes; |
136 val local_thmss = Scan.repeat local_thms >> flat; |
136 val local_thmss = Scan.repeat local_thms >> flat; |
137 |
137 |
138 |
138 |
139 |
139 |
140 (** attribute syntax **) |
140 (** attribute syntax **) |
149 |
149 |
150 (** Pure attributes **) |
150 (** Pure attributes **) |
151 |
151 |
152 (* tags *) |
152 (* tags *) |
153 |
153 |
154 fun gen_tag x = syntax (tag >> Attribute.tag) x; |
154 fun gen_tag x = syntax (tag >> Drule.tag) x; |
155 fun gen_untag x = syntax (tag >> Attribute.untag) x; |
155 fun gen_untag x = syntax (tag >> Drule.untag) x; |
156 |
156 |
157 |
157 |
158 (* transfer *) |
158 (* transfer *) |
159 |
159 |
160 fun gen_transfer theory_of = no_args (Attribute.rule (fn st => Thm.transfer (theory_of st))); |
160 fun gen_transfer theory_of = no_args (Drule.rule_attribute (fn st => Thm.transfer (theory_of st))); |
161 |
161 |
162 val global_transfer = gen_transfer I; |
162 val global_transfer = gen_transfer I; |
163 val local_transfer = gen_transfer ProofContext.theory_of; |
163 val local_transfer = gen_transfer ProofContext.theory_of; |
164 |
164 |
165 |
165 |
166 (* RS *) |
166 (* RS *) |
167 |
167 |
168 fun resolve (i, B) (x, A) = |
168 fun resolve (i, B) (x, A) = (x, A RSN (i, B)); |
169 (x, Attribute.tthm_of (Attribute.thm_of A RSN (i, Attribute.thm_of B))); |
|
170 |
169 |
171 fun gen_RS thm = syntax (Scan.lift (Scan.optional Args.nat 1) -- thm >> resolve); |
170 fun gen_RS thm = syntax (Scan.lift (Scan.optional Args.nat 1) -- thm >> resolve); |
172 val global_RS = gen_RS global_thm; |
171 val global_RS = gen_RS global_thm; |
173 val local_RS = gen_RS local_thm; |
172 val local_RS = gen_RS local_thm; |
174 |
173 |
175 |
174 |
176 (* APP *) |
175 (* APP *) |
177 |
176 |
178 fun apply Bs (x, A) = |
177 fun apply Bs (x, A) = (x, Bs MRS A); |
179 (x, Attribute.tthm_of (Attribute.thms_of Bs MRS Attribute.thm_of A)); |
|
180 |
178 |
181 val global_APP = syntax (global_thmss >> apply); |
179 val global_APP = syntax (global_thmss >> apply); |
182 val local_APP = syntax (local_thmss >> apply); |
180 val local_APP = syntax (local_thmss >> apply); |
183 |
181 |
184 |
182 |
205 (gen_distinct (fn ((x1, t1), (x2, t2)) => x1 = x2 andalso t1 aconv t2) (xs ~~ ts)); |
203 (gen_distinct (fn ((x1, t1), (x2, t2)) => x1 = x2 andalso t1 aconv t2) (xs ~~ ts)); |
206 in Thm.instantiate (cenvT, cenv) thm end; |
204 in Thm.instantiate (cenvT, cenv) thm end; |
207 |
205 |
208 fun insts x = Scan.lift (Args.enum "and" (Args.var --| Args.$$$ "=" -- Args.name)) x; |
206 fun insts x = Scan.lift (Args.enum "and" (Args.var --| Args.$$$ "=" -- Args.name)) x; |
209 |
207 |
210 fun gen_where context_of = syntax (insts >> (Attribute.rule o read_instantiate context_of)); |
208 fun gen_where context_of = syntax (insts >> (Drule.rule_attribute o read_instantiate context_of)); |
211 |
209 |
212 val global_where = gen_where ProofContext.init; |
210 val global_where = gen_where ProofContext.init; |
213 val local_where = gen_where I; |
211 val local_where = gen_where I; |
214 |
212 |
215 |
213 |
229 val concl = Args.$$$ "concl" -- Args.$$$ ":"; |
227 val concl = Args.$$$ "concl" -- Args.$$$ ":"; |
230 val inst_arg = Scan.unless concl (Args.$$$ "_" >> K None || Args.name >> Some); |
228 val inst_arg = Scan.unless concl (Args.$$$ "_" >> K None || Args.name >> Some); |
231 val inst_args = Scan.repeat inst_arg; |
229 val inst_args = Scan.repeat inst_arg; |
232 fun insts' x = Scan.lift (inst_args -- Scan.optional (concl |-- Args.!!! inst_args) []) x; |
230 fun insts' x = Scan.lift (inst_args -- Scan.optional (concl |-- Args.!!! inst_args) []) x; |
233 |
231 |
234 fun gen_with context_of = syntax (insts' >> (Attribute.rule o read_instantiate' context_of)); |
232 fun gen_with context_of = syntax (insts' >> (Drule.rule_attribute o read_instantiate' context_of)); |
235 |
233 |
236 val global_with = gen_with ProofContext.init; |
234 val global_with = gen_with ProofContext.init; |
237 val local_with = gen_with I; |
235 val local_with = gen_with I; |
238 |
236 |
239 |
237 |
240 (* misc rules *) |
238 (* misc rules *) |
241 |
239 |
242 fun standard x = no_args (Attribute.rule (K Drule.standard)) x; |
240 fun standard x = no_args (Drule.rule_attribute (K Drule.standard)) x; |
243 fun elimify x = no_args (Attribute.rule (K Tactic.make_elim)) x; |
241 fun elimify x = no_args (Drule.rule_attribute (K Tactic.make_elim)) x; |
244 |
242 |
245 |
243 |
246 |
244 |
247 (** theory setup **) |
245 (** theory setup **) |
248 |
246 |