168 val fns = {is_const = is_const phi, dest_const = dest_const phi, |
168 val fns = {is_const = is_const phi, dest_const = dest_const phi, |
169 mk_const = mk_const phi, conv = conv phi}; |
169 mk_const = mk_const phi, conv = conv phi}; |
170 in AList.map_entry Thm.eq_thm key (apsnd (K fns)) data end); |
170 in AList.map_entry Thm.eq_thm key (apsnd (K fns)) data end); |
171 |
171 |
172 |
172 |
173 (* Very basic stuff for terms *) |
173 (** auxiliary **) |
174 |
174 |
175 fun is_comb ct = |
175 fun is_comb ct = |
176 (case Thm.term_of ct of |
176 (case Thm.term_of ct of |
177 _ $ _ => true |
177 _ $ _ => true |
178 | _ => false); |
178 | _ => false); |
214 val zeron_tm = @{cterm "0::nat"}; |
214 val zeron_tm = @{cterm "0::nat"}; |
215 val onen_tm = @{cterm "1::nat"}; |
215 val onen_tm = @{cterm "1::nat"}; |
216 val true_tm = @{cterm "True"}; |
216 val true_tm = @{cterm "True"}; |
217 |
217 |
218 |
218 |
219 (* The main function! *) |
219 (** normalizing conversions **) |
|
220 |
|
221 (* core conversion *) |
|
222 |
220 fun semiring_normalizers_conv vars (sr_ops, sr_rules) (r_ops, r_rules) (f_ops, f_rules) |
223 fun semiring_normalizers_conv vars (sr_ops, sr_rules) (r_ops, r_rules) (f_ops, f_rules) |
221 (is_semiring_constant, semiring_add_conv, semiring_mul_conv, semiring_pow_conv) = |
224 (is_semiring_constant, semiring_add_conv, semiring_mul_conv, semiring_pow_conv) = |
222 let |
225 let |
223 |
226 |
224 val [pthm_02, pthm_03, pthm_04, pthm_05, pthm_07, pthm_08, |
227 val [pthm_02, pthm_03, pthm_04, pthm_05, pthm_07, pthm_08, |
782 HOL_basic_ss addsimps (@{thms nat_number} @ @{thms nat_arith} @ @{thms arith_simps} @ @{thms rel_simps}) |
785 HOL_basic_ss addsimps (@{thms nat_number} @ @{thms nat_arith} @ @{thms arith_simps} @ @{thms rel_simps}) |
783 addsimps [@{thm Let_def}, @{thm if_False}, @{thm if_True}, @{thm Nat.add_0}, @{thm add_Suc}]; |
786 addsimps [@{thm Let_def}, @{thm if_False}, @{thm if_True}, @{thm Nat.add_0}, @{thm add_Suc}]; |
784 |
787 |
785 fun simple_cterm_ord t u = Term_Ord.term_ord (term_of t, term_of u) = LESS; |
788 fun simple_cterm_ord t u = Term_Ord.term_ord (term_of t, term_of u) = LESS; |
786 |
789 |
|
790 |
|
791 (* various normalizing conversions *) |
|
792 |
787 fun semiring_normalizers_ord_wrapper ctxt ({vars, semiring, ring, field, idom, ideal}, |
793 fun semiring_normalizers_ord_wrapper ctxt ({vars, semiring, ring, field, idom, ideal}, |
788 {conv, dest_const, mk_const, is_const}) ord = |
794 {conv, dest_const, mk_const, is_const}) ord = |
789 let |
795 let |
790 val pow_conv = |
796 val pow_conv = |
791 Conv.arg_conv (Simplifier.rewrite nat_exp_ss) |
797 Conv.arg_conv (Simplifier.rewrite nat_exp_ss) |