167 |
167 |
168 |
168 |
169 (* theorems *) |
169 (* theorems *) |
170 |
170 |
171 fun gen_thm theory_of attrib get pick = Scan.depend (fn st => |
171 fun gen_thm theory_of attrib get pick = Scan.depend (fn st => |
172 Scan.ahead Args.name -- Args.named_fact (fn name => get st (Name name)) -- |
172 (Scan.ahead Args.alt_name -- Args.named_fact (get st o Fact) |
173 Scan.option Args.thm_sel -- Args.opt_attribs (intern (theory_of st)) |
173 >> (fn (s, fact) => ("", Fact s, fact)) || |
174 >> (fn (((name, fact), sel), srcs) => |
174 Scan.ahead Args.name -- Args.named_fact (get st o Name) -- Args.thm_sel |
|
175 >> (fn ((name, fact), sel) => (name, NameSelection (name, sel), fact)) || |
|
176 Scan.ahead Args.name -- Args.named_fact (get st o Name) |
|
177 >> (fn (name, fact) => (name, Name name, fact))) -- |
|
178 Args.opt_attribs (intern (theory_of st)) |
|
179 >> (fn ((name, thmref, fact), srcs) => |
175 let |
180 let |
176 val thmref = (case sel of NONE => Name name | SOME is => NameSelection (name, is)); |
|
177 val ths = PureThy.select_thm thmref fact; |
181 val ths = PureThy.select_thm thmref fact; |
178 val atts = map (attrib (theory_of st)) srcs; |
182 val atts = map (attrib (theory_of st)) srcs; |
179 val (st', ths') = Thm.applys_attributes ((st, ths), atts); |
183 val (st', ths') = Thm.applys_attributes ((st, ths), atts); |
180 in (st', pick name ths') end)); |
184 in (st', pick name ths') end)); |
181 |
185 |