equal
deleted
inserted
replaced
265 |> Sign.add_const_constraint_i (c, ty2) |
265 |> Sign.add_const_constraint_i (c, ty2) |
266 |> pair (c, ty1) |
266 |> pair (c, ty1) |
267 end; |
267 end; |
268 fun check_defs raw_defs c_req thy = |
268 fun check_defs raw_defs c_req thy = |
269 let |
269 let |
270 val thy' = Sign.add_arities_i [(tyco, asorts, sort)] thy; |
270 val thy' = thy |> Theory.copy |> Sign.add_arities_i [(tyco, asorts, sort)]; |
271 val c_given = map (fst o Sign.cert_def pp o snd o tap_def thy' o fst) raw_defs; |
271 fun get_c raw_def = |
|
272 (fst o Sign.cert_def pp o snd o tap_def thy' o fst) raw_def; |
|
273 val c_given = map get_c raw_defs; |
|
274 (* spec_opt_name *) |
272 fun eq_c ((c1, ty1), (c2, ty2)) = |
275 fun eq_c ((c1, ty1), (c2, ty2)) = |
273 let |
276 let |
274 val ty1' = Type.varifyT ty1; |
277 val ty1' = Type.varifyT ty1; |
275 val ty2' = Type.varifyT ty2; |
278 val ty2' = Type.varifyT ty2; |
276 in |
279 in |
296 |> fold_map get_remove_contraint (map fst c_req) |
299 |> fold_map get_remove_contraint (map fst c_req) |
297 ||> add_defs (true, raw_defs) |
300 ||> add_defs (true, raw_defs) |
298 |-> (fn cs => AxClass.instance_arity_i (after_qed cs) arity) |
301 |-> (fn cs => AxClass.instance_arity_i (after_qed cs) arity) |
299 end; |
302 end; |
300 |
303 |
301 val add_instance_arity = fn x => gen_instance_arity (AxClass.read_arity) IsarThy.add_defs read_axm x; |
304 val add_instance_arity = gen_instance_arity (AxClass.read_arity) IsarThy.add_defs read_axm; |
302 val add_instance_arity_i = fn x => gen_instance_arity (AxClass.cert_arity) IsarThy.add_defs_i (K I) x; |
305 val add_instance_arity_i = gen_instance_arity (AxClass.cert_arity) IsarThy.add_defs_i (K I); |
303 |
306 |
304 |
307 |
305 (* queries *) |
308 (* queries *) |
306 |
309 |
307 fun is_class thy cls = |
310 fun is_class thy cls = |
519 val classP_exp = |
522 val classP_exp = |
520 OuterSyntax.command (classK ^ "_exp") "operational type classes" K.thy_goal ( |
523 OuterSyntax.command (classK ^ "_exp") "operational type classes" K.thy_goal ( |
521 P.name --| P.$$$ "=" |
524 P.name --| P.$$$ "=" |
522 -- Scan.optional (Scan.repeat1 (P.name --| P.$$$ "+")) [] |
525 -- Scan.optional (Scan.repeat1 (P.name --| P.$$$ "+")) [] |
523 -- Scan.optional (P.!!! (Scan.repeat1 P.context_element)) [] |
526 -- Scan.optional (P.!!! (Scan.repeat1 P.context_element)) [] |
524 >> (Toplevel.theory_to_proof |
527 >> (Toplevel.print oo Toplevel.theory_to_proof |
525 o (fn ((bname, supclasses), elems) => add_class_exp bname supclasses elems))); |
528 o (fn ((bname, supclasses), elems) => add_class_exp bname supclasses elems))); |
526 |
529 |
527 val instanceP = |
530 val instanceP = |
528 OuterSyntax.command instanceK "prove type arity or subclass relation" K.thy_goal (( |
531 OuterSyntax.command instanceK "prove type arity or subclass relation" K.thy_goal (( |
529 P.xname -- ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- P.!!! P.xname) >> AxClass.instance_subclass |
532 P.xname -- ((P.$$$ "\\<subseteq>" || P.$$$ "<") |-- P.!!! P.xname) >> AxClass.instance_subclass |