49 (typedef_term rel rty lthy) NONE typedef_tac lthy |
49 (typedef_term rel rty lthy) NONE typedef_tac lthy |
50 end |
50 end |
51 |
51 |
52 |
52 |
53 (* tactic to prove the quot_type theorem for the new type *) |
53 (* tactic to prove the quot_type theorem for the new type *) |
54 fun typedef_quot_type_tac equiv_thm ((_, typedef_info): Typedef.info) = |
54 fun typedef_quot_type_tac ctxt equiv_thm ((_, typedef_info): Typedef.info) = |
55 let |
55 let |
56 val rep_thm = #Rep typedef_info RS mem_def1 |
56 val rep_thm = #Rep typedef_info RS mem_def1 |
57 val rep_inv = #Rep_inverse typedef_info |
57 val rep_inv = #Rep_inverse typedef_info |
58 val abs_inv = #Abs_inverse typedef_info |
58 val abs_inv = #Abs_inverse typedef_info |
59 val rep_inj = #Rep_inject typedef_info |
59 val rep_inj = #Rep_inject typedef_info |
60 in |
60 in |
61 (rtac @{thm quot_type.intro} THEN' RANGE [ |
61 (rtac @{thm quot_type.intro} THEN' RANGE [ |
62 rtac equiv_thm, |
62 rtac equiv_thm, |
63 rtac rep_thm, |
63 rtac rep_thm, |
64 rtac rep_inv, |
64 rtac rep_inv, |
65 rtac abs_inv THEN' rtac mem_def2 THEN' atac, |
65 rtac abs_inv THEN' rtac mem_def2 THEN' assume_tac ctxt, |
66 rtac rep_inj]) 1 |
66 rtac rep_inj]) 1 |
67 end |
67 end |
68 |
68 |
69 (* proves the quot_type theorem for the new type *) |
69 (* proves the quot_type theorem for the new type *) |
70 fun typedef_quot_type_thm (rel, abs, rep, equiv_thm, typedef_info) lthy = |
70 fun typedef_quot_type_thm (rel, abs, rep, equiv_thm, typedef_info) lthy = |
72 val quot_type_const = Const (@{const_name "quot_type"}, |
72 val quot_type_const = Const (@{const_name "quot_type"}, |
73 fastype_of rel --> fastype_of abs --> fastype_of rep --> @{typ bool}) |
73 fastype_of rel --> fastype_of abs --> fastype_of rep --> @{typ bool}) |
74 val goal = HOLogic.mk_Trueprop (quot_type_const $ rel $ abs $ rep) |
74 val goal = HOLogic.mk_Trueprop (quot_type_const $ rel $ abs $ rep) |
75 in |
75 in |
76 Goal.prove lthy [] [] goal |
76 Goal.prove lthy [] [] goal |
77 (K (typedef_quot_type_tac equiv_thm typedef_info)) |
77 (fn {context = ctxt, ...} => typedef_quot_type_tac ctxt equiv_thm typedef_info) |
78 end |
78 end |
79 |
79 |
80 open Lifting_Util |
80 open Lifting_Util |
81 |
81 |
82 infix 0 MRSL |
82 infix 0 MRSL |