230 |
230 |
231 (** instances with implicit parameter handling **) |
231 (** instances with implicit parameter handling **) |
232 |
232 |
233 local |
233 local |
234 |
234 |
235 fun gen_read_def thy prep_att read_def ((raw_name, raw_atts), raw_t) = |
235 fun gen_read_def thy prep_att parse_prop ((raw_name, raw_atts), raw_t) = |
236 let |
236 let |
237 val (_, t) = read_def thy (raw_name, raw_t); |
237 val ctxt = ProofContext.init thy; |
|
238 val t = parse_prop ctxt raw_t |> Syntax.check_prop ctxt; |
238 val ((c, ty), _) = Sign.cert_def (Sign.pp thy) t; |
239 val ((c, ty), _) = Sign.cert_def (Sign.pp thy) t; |
239 val atts = map (prep_att thy) raw_atts; |
240 val atts = map (prep_att thy) raw_atts; |
240 val insts = Consts.typargs (Sign.consts_of thy) (c, ty); |
241 val insts = Consts.typargs (Sign.consts_of thy) (c, ty); |
241 val name = case raw_name |
242 val name = case raw_name |
242 of "" => NONE |
243 of "" => NONE |
243 | _ => SOME raw_name; |
244 | _ => SOME raw_name; |
244 in (c, (insts, ((name, t), atts))) end; |
245 in (c, (insts, ((name, t), atts))) end; |
245 |
246 |
246 fun read_def_cmd thy = gen_read_def thy Attrib.intern_src Theory.read_axm; |
247 fun read_def_cmd thy = gen_read_def thy Attrib.intern_src Syntax.parse_prop; |
247 fun read_def thy = gen_read_def thy (K I) (K I); |
248 fun read_def thy = gen_read_def thy (K I) (K I); |
248 |
249 |
249 fun gen_instance prep_arity read_def do_proof raw_arities raw_defs after_qed theory = |
250 fun gen_instance prep_arity read_def do_proof raw_arities raw_defs after_qed theory = |
250 let |
251 let |
251 val arities = map (prep_arity theory) raw_arities; |
252 val arities = map (prep_arity theory) raw_arities; |
542 |
543 |
543 (* class definition *) |
544 (* class definition *) |
544 |
545 |
545 local |
546 local |
546 |
547 |
547 fun read_param thy raw_t = |
548 fun read_param thy raw_t = (* FIXME ProofContext.read_const (!?) *) |
548 let |
549 let |
549 val t = Sign.read_term thy raw_t |
550 val t = Syntax.read_term_global thy raw_t |
550 in case try dest_Const t |
551 in case try dest_Const t |
551 of SOME (c, _) => c |
552 of SOME (c, _) => c |
552 | NONE => error ("Not a constant: " ^ Sign.string_of_term thy t) |
553 | NONE => error ("Not a constant: " ^ Sign.string_of_term thy t) |
553 end; |
554 end; |
554 |
555 |