62 fun termless_ring (a, b) = (term_lpo ring_ord (a, b) = LESS); |
62 fun termless_ring (a, b) = (term_lpo ring_ord (a, b) = LESS); |
63 |
63 |
64 val cring_ss = HOL_ss settermless termless_ring; |
64 val cring_ss = HOL_ss settermless termless_ring; |
65 |
65 |
66 fun cring_normalise ctxt = let |
66 fun cring_normalise ctxt = let |
67 fun filter t = (case HOLogic.dest_Trueprop t of |
67 fun ring_filter t = (case HOLogic.dest_Trueprop t of |
68 Const ("CRing.cring_axioms", _) $ Free (s, _) => [s] |
68 Const ("CRing.ring_axioms", _) $ Free (s, _) => [s] |
69 | _ => []) |
69 | _ => []) |
70 handle TERM _ => []; |
70 handle TERM _ => []; |
71 val insts = flat (map (filter o #prop o rep_thm) |
71 fun comm_filter t = (case HOLogic.dest_Trueprop t of |
72 (ProofContext.prems_of ctxt)); |
72 Const ("Group.comm_semigroup_axioms", _) $ Free (s, _) => [s] |
73 val _ = warning ("Rings in proof context: " ^ implode insts); |
73 | _ => []) |
|
74 handle TERM _ => []; |
|
75 |
|
76 val prems = ProofContext.prems_of ctxt; |
|
77 val rings = flat (map (ring_filter o #prop o rep_thm) prems); |
|
78 val comms = flat (map (comm_filter o #prop o rep_thm) prems); |
|
79 val non_comm_rings = rings \\ comms; |
|
80 val comm_rings = rings inter_string comms; |
|
81 val _ = tracing |
|
82 ("Non-commutative rings in proof context: " ^ commas non_comm_rings ^ |
|
83 "\nCommutative rings in proof context: " ^ commas comm_rings); |
74 val simps = |
84 val simps = |
|
85 flat (map (fn s => ProofContext.get_thms ctxt (s ^ ".ring_simprules")) |
|
86 non_comm_rings) @ |
75 flat (map (fn s => ProofContext.get_thms ctxt (s ^ ".cring_simprules")) |
87 flat (map (fn s => ProofContext.get_thms ctxt (s ^ ".cring_simprules")) |
76 insts); |
88 comm_rings); |
77 in Method.SIMPLE_METHOD' HEADGOAL (asm_full_simp_tac (cring_ss addsimps simps)) |
89 in Method.SIMPLE_METHOD' HEADGOAL (asm_full_simp_tac (cring_ss addsimps simps)) |
78 end; |
90 end; |
79 |
91 |
80 (* |
92 (* |
81 val ring_ss = HOL_basic_ss settermless termless_ring addsimps |
93 val ring_ss = HOL_basic_ss settermless termless_ring addsimps |