120 ML_file "Tools/proof_general_pure.ML" |
120 ML_file "Tools/proof_general_pure.ML" |
121 ML_file "Tools/simplifier_trace.ML" |
121 ML_file "Tools/simplifier_trace.ML" |
122 ML_file "Tools/named_theorems.ML" |
122 ML_file "Tools/named_theorems.ML" |
123 |
123 |
124 |
124 |
125 section {* Basic attributes *} |
125 section \<open>Basic attributes\<close> |
126 |
126 |
127 attribute_setup tagged = |
127 attribute_setup tagged = |
128 "Scan.lift (Args.name -- Args.name) >> Thm.tag" |
128 \<open>Scan.lift (Args.name -- Args.name) >> Thm.tag\<close> |
129 "tagged theorem" |
129 "tagged theorem" |
130 |
130 |
131 attribute_setup untagged = |
131 attribute_setup untagged = |
132 "Scan.lift Args.name >> Thm.untag" |
132 \<open>Scan.lift Args.name >> Thm.untag\<close> |
133 "untagged theorem" |
133 "untagged theorem" |
134 |
134 |
135 attribute_setup kind = |
135 attribute_setup kind = |
136 "Scan.lift Args.name >> Thm.kind" |
136 \<open>Scan.lift Args.name >> Thm.kind\<close> |
137 "theorem kind" |
137 "theorem kind" |
138 |
138 |
139 attribute_setup THEN = |
139 attribute_setup THEN = |
140 "Scan.lift (Scan.optional (Args.bracks Parse.nat) 1) -- Attrib.thm |
140 \<open>Scan.lift (Scan.optional (Args.bracks Parse.nat) 1) -- Attrib.thm |
141 >> (fn (i, B) => Thm.rule_attribute (fn _ => fn A => A RSN (i, B)))" |
141 >> (fn (i, B) => Thm.rule_attribute (fn _ => fn A => A RSN (i, B)))\<close> |
142 "resolution with rule" |
142 "resolution with rule" |
143 |
143 |
144 attribute_setup OF = |
144 attribute_setup OF = |
145 "Attrib.thms >> (fn Bs => Thm.rule_attribute (fn _ => fn A => A OF Bs))" |
145 \<open>Attrib.thms >> (fn Bs => Thm.rule_attribute (fn _ => fn A => A OF Bs))\<close> |
146 "rule resolved with facts" |
146 "rule resolved with facts" |
147 |
147 |
148 attribute_setup rename_abs = |
148 attribute_setup rename_abs = |
149 "Scan.lift (Scan.repeat (Args.maybe Args.name)) >> (fn vs => |
149 \<open>Scan.lift (Scan.repeat (Args.maybe Args.name)) >> (fn vs => |
150 Thm.rule_attribute (K (Drule.rename_bvars' vs)))" |
150 Thm.rule_attribute (K (Drule.rename_bvars' vs)))\<close> |
151 "rename bound variables in abstractions" |
151 "rename bound variables in abstractions" |
152 |
152 |
153 attribute_setup unfolded = |
153 attribute_setup unfolded = |
154 "Attrib.thms >> (fn ths => |
154 \<open>Attrib.thms >> (fn ths => |
155 Thm.rule_attribute (fn context => Local_Defs.unfold (Context.proof_of context) ths))" |
155 Thm.rule_attribute (fn context => Local_Defs.unfold (Context.proof_of context) ths))\<close> |
156 "unfolded definitions" |
156 "unfolded definitions" |
157 |
157 |
158 attribute_setup folded = |
158 attribute_setup folded = |
159 "Attrib.thms >> (fn ths => |
159 \<open>Attrib.thms >> (fn ths => |
160 Thm.rule_attribute (fn context => Local_Defs.fold (Context.proof_of context) ths))" |
160 Thm.rule_attribute (fn context => Local_Defs.fold (Context.proof_of context) ths))\<close> |
161 "folded definitions" |
161 "folded definitions" |
162 |
162 |
163 attribute_setup consumes = |
163 attribute_setup consumes = |
164 "Scan.lift (Scan.optional Parse.int 1) >> Rule_Cases.consumes" |
164 \<open>Scan.lift (Scan.optional Parse.int 1) >> Rule_Cases.consumes\<close> |
165 "number of consumed facts" |
165 "number of consumed facts" |
166 |
166 |
167 attribute_setup constraints = |
167 attribute_setup constraints = |
168 "Scan.lift Parse.nat >> Rule_Cases.constraints" |
168 \<open>Scan.lift Parse.nat >> Rule_Cases.constraints\<close> |
169 "number of equality constraints" |
169 "number of equality constraints" |
170 |
170 |
171 attribute_setup case_names = {* |
171 attribute_setup case_names = |
172 Scan.lift (Scan.repeat1 (Args.name -- |
172 \<open>Scan.lift (Scan.repeat1 (Args.name -- |
173 Scan.optional (@{keyword "["} |-- Scan.repeat1 (Args.maybe Args.name) --| @{keyword "]"}) [])) |
173 Scan.optional (@{keyword "["} |-- Scan.repeat1 (Args.maybe Args.name) --| @{keyword "]"}) [])) |
174 >> (fn cs => |
174 >> (fn cs => |
175 Rule_Cases.cases_hyp_names |
175 Rule_Cases.cases_hyp_names |
176 (map #1 cs) |
176 (map #1 cs) |
177 (map (map (the_default Rule_Cases.case_hypsN) o #2) cs)) |
177 (map (map (the_default Rule_Cases.case_hypsN) o #2) cs))\<close> |
178 *} "named rule cases" |
178 "named rule cases" |
179 |
179 |
180 attribute_setup case_conclusion = |
180 attribute_setup case_conclusion = |
181 "Scan.lift (Args.name -- Scan.repeat Args.name) >> Rule_Cases.case_conclusion" |
181 \<open>Scan.lift (Args.name -- Scan.repeat Args.name) >> Rule_Cases.case_conclusion\<close> |
182 "named conclusion of rule cases" |
182 "named conclusion of rule cases" |
183 |
183 |
184 attribute_setup params = |
184 attribute_setup params = |
185 "Scan.lift (Parse.and_list1 (Scan.repeat Args.name)) >> Rule_Cases.params" |
185 \<open>Scan.lift (Parse.and_list1 (Scan.repeat Args.name)) >> Rule_Cases.params\<close> |
186 "named rule parameters" |
186 "named rule parameters" |
187 |
187 |
188 attribute_setup rule_format = {* |
188 attribute_setup rule_format = |
189 Scan.lift (Args.mode "no_asm") |
189 \<open>Scan.lift (Args.mode "no_asm") |
190 >> (fn true => Object_Logic.rule_format_no_asm | false => Object_Logic.rule_format) |
190 >> (fn true => Object_Logic.rule_format_no_asm | false => Object_Logic.rule_format)\<close> |
191 *} "result put into canonical rule format" |
191 "result put into canonical rule format" |
192 |
192 |
193 attribute_setup elim_format = |
193 attribute_setup elim_format = |
194 "Scan.succeed (Thm.rule_attribute (K Tactic.make_elim))" |
194 \<open>Scan.succeed (Thm.rule_attribute (K Tactic.make_elim))\<close> |
195 "destruct rule turned into elimination rule format" |
195 "destruct rule turned into elimination rule format" |
196 |
196 |
197 attribute_setup no_vars = {* |
197 attribute_setup no_vars = |
198 Scan.succeed (Thm.rule_attribute (fn context => fn th => |
198 \<open>Scan.succeed (Thm.rule_attribute (fn context => fn th => |
199 let |
199 let |
200 val ctxt = Variable.set_body false (Context.proof_of context); |
200 val ctxt = Variable.set_body false (Context.proof_of context); |
201 val ((_, [th']), _) = Variable.import true [th] ctxt; |
201 val ((_, [th']), _) = Variable.import true [th] ctxt; |
202 in th' end)) |
202 in th' end))\<close> |
203 *} "imported schematic variables" |
203 "imported schematic variables" |
204 |
204 |
205 attribute_setup eta_long = |
205 attribute_setup eta_long = |
206 "Scan.succeed (Thm.rule_attribute (fn _ => Conv.fconv_rule Drule.eta_long_conversion))" |
206 \<open>Scan.succeed (Thm.rule_attribute (fn _ => Conv.fconv_rule Drule.eta_long_conversion))\<close> |
207 "put theorem into eta long beta normal form" |
207 "put theorem into eta long beta normal form" |
208 |
208 |
209 attribute_setup atomize = |
209 attribute_setup atomize = |
210 "Scan.succeed Object_Logic.declare_atomize" |
210 \<open>Scan.succeed Object_Logic.declare_atomize\<close> |
211 "declaration of atomize rule" |
211 "declaration of atomize rule" |
212 |
212 |
213 attribute_setup rulify = |
213 attribute_setup rulify = |
214 "Scan.succeed Object_Logic.declare_rulify" |
214 \<open>Scan.succeed Object_Logic.declare_rulify\<close> |
215 "declaration of rulify rule" |
215 "declaration of rulify rule" |
216 |
216 |
217 attribute_setup rotated = |
217 attribute_setup rotated = |
218 "Scan.lift (Scan.optional Parse.int 1 |
218 \<open>Scan.lift (Scan.optional Parse.int 1 |
219 >> (fn n => Thm.rule_attribute (fn _ => rotate_prems n)))" |
219 >> (fn n => Thm.rule_attribute (fn _ => rotate_prems n)))\<close> |
220 "rotated theorem premises" |
220 "rotated theorem premises" |
221 |
221 |
222 attribute_setup defn = |
222 attribute_setup defn = |
223 "Attrib.add_del Local_Defs.defn_add Local_Defs.defn_del" |
223 \<open>Attrib.add_del Local_Defs.defn_add Local_Defs.defn_del\<close> |
224 "declaration of definitional transformations" |
224 "declaration of definitional transformations" |
225 |
225 |
226 attribute_setup abs_def = |
226 attribute_setup abs_def = |
227 "Scan.succeed (Thm.rule_attribute (fn context => |
227 \<open>Scan.succeed (Thm.rule_attribute (fn context => |
228 Local_Defs.meta_rewrite_rule (Context.proof_of context) #> Drule.abs_def))" |
228 Local_Defs.meta_rewrite_rule (Context.proof_of context) #> Drule.abs_def))\<close> |
229 "abstract over free variables of definitional theorem" |
229 "abstract over free variables of definitional theorem" |
230 |
230 |
231 |
231 |
232 section {* Further content for the Pure theory *} |
232 section \<open>Further content for the Pure theory\<close> |
233 |
233 |
234 subsection {* Meta-level connectives in assumptions *} |
234 subsection \<open>Meta-level connectives in assumptions\<close> |
235 |
235 |
236 lemma meta_mp: |
236 lemma meta_mp: |
237 assumes "PROP P ==> PROP Q" and "PROP P" |
237 assumes "PROP P ==> PROP Q" and "PROP P" |
238 shows "PROP Q" |
238 shows "PROP Q" |
239 by (rule `PROP P ==> PROP Q` [OF `PROP P`]) |
239 by (rule \<open>PROP P ==> PROP Q\<close> [OF \<open>PROP P\<close>]) |
240 |
240 |
241 lemmas meta_impE = meta_mp [elim_format] |
241 lemmas meta_impE = meta_mp [elim_format] |
242 |
242 |
243 lemma meta_spec: |
243 lemma meta_spec: |
244 assumes "!!x. PROP P x" |
244 assumes "!!x. PROP P x" |
245 shows "PROP P x" |
245 shows "PROP P x" |
246 by (rule `!!x. PROP P x`) |
246 by (rule \<open>!!x. PROP P x\<close>) |
247 |
247 |
248 lemmas meta_allE = meta_spec [elim_format] |
248 lemmas meta_allE = meta_spec [elim_format] |
249 |
249 |
250 lemma swap_params: |
250 lemma swap_params: |
251 "(!!x y. PROP P x y) == (!!y x. PROP P x y)" .. |
251 "(!!x y. PROP P x y) == (!!y x. PROP P x y)" .. |
252 |
252 |
253 |
253 |
254 subsection {* Meta-level conjunction *} |
254 subsection \<open>Meta-level conjunction\<close> |
255 |
255 |
256 lemma all_conjunction: |
256 lemma all_conjunction: |
257 "(!!x. PROP A x &&& PROP B x) == ((!!x. PROP A x) &&& (!!x. PROP B x))" |
257 "(!!x. PROP A x &&& PROP B x) == ((!!x. PROP A x) &&& (!!x. PROP B x))" |
258 proof |
258 proof |
259 assume conj: "!!x. PROP A x &&& PROP B x" |
259 assume conj: "!!x. PROP A x &&& PROP B x" |