1114 declare (in neg_numeral) add_neg_numeral_special [simp] |
1128 declare (in neg_numeral) add_neg_numeral_special [simp] |
1115 declare (in neg_numeral) diff_numeral_simps [simp] |
1129 declare (in neg_numeral) diff_numeral_simps [simp] |
1116 declare (in neg_numeral) diff_numeral_special [simp] |
1130 declare (in neg_numeral) diff_numeral_special [simp] |
1117 declare (in semiring_numeral) numeral_times_numeral [simp] |
1131 declare (in semiring_numeral) numeral_times_numeral [simp] |
1118 declare (in ring_1) mult_neg_numeral_simps [simp] |
1132 declare (in ring_1) mult_neg_numeral_simps [simp] |
|
1133 |
|
1134 |
|
1135 subsubsection \<open>Special Simplification for Constants\<close> |
|
1136 |
|
1137 text \<open>These distributive laws move literals inside sums and differences.\<close> |
|
1138 |
|
1139 lemmas distrib_right_numeral [simp] = distrib_right [of _ _ "numeral v"] for v |
|
1140 lemmas distrib_left_numeral [simp] = distrib_left [of "numeral v"] for v |
|
1141 lemmas left_diff_distrib_numeral [simp] = left_diff_distrib [of _ _ "numeral v"] for v |
|
1142 lemmas right_diff_distrib_numeral [simp] = right_diff_distrib [of "numeral v"] for v |
|
1143 |
|
1144 text \<open>These are actually for fields, like real\<close> |
|
1145 |
|
1146 lemmas zero_less_divide_iff_numeral [simp, no_atp] = zero_less_divide_iff [of "numeral w"] for w |
|
1147 lemmas divide_less_0_iff_numeral [simp, no_atp] = divide_less_0_iff [of "numeral w"] for w |
|
1148 lemmas zero_le_divide_iff_numeral [simp, no_atp] = zero_le_divide_iff [of "numeral w"] for w |
|
1149 lemmas divide_le_0_iff_numeral [simp, no_atp] = divide_le_0_iff [of "numeral w"] for w |
|
1150 |
|
1151 text \<open>Replaces \<open>inverse #nn\<close> by \<open>1/#nn\<close>. It looks |
|
1152 strange, but then other simprocs simplify the quotient.\<close> |
|
1153 |
|
1154 lemmas inverse_eq_divide_numeral [simp] = |
|
1155 inverse_eq_divide [of "numeral w"] for w |
|
1156 |
|
1157 lemmas inverse_eq_divide_neg_numeral [simp] = |
|
1158 inverse_eq_divide [of "- numeral w"] for w |
|
1159 |
|
1160 text \<open>These laws simplify inequalities, moving unary minus from a term |
|
1161 into the literal.\<close> |
|
1162 |
|
1163 lemmas equation_minus_iff_numeral [no_atp] = |
|
1164 equation_minus_iff [of "numeral v"] for v |
|
1165 |
|
1166 lemmas minus_equation_iff_numeral [no_atp] = |
|
1167 minus_equation_iff [of _ "numeral v"] for v |
|
1168 |
|
1169 lemmas le_minus_iff_numeral [no_atp] = |
|
1170 le_minus_iff [of "numeral v"] for v |
|
1171 |
|
1172 lemmas minus_le_iff_numeral [no_atp] = |
|
1173 minus_le_iff [of _ "numeral v"] for v |
|
1174 |
|
1175 lemmas less_minus_iff_numeral [no_atp] = |
|
1176 less_minus_iff [of "numeral v"] for v |
|
1177 |
|
1178 lemmas minus_less_iff_numeral [no_atp] = |
|
1179 minus_less_iff [of _ "numeral v"] for v |
|
1180 |
|
1181 (* FIXME maybe simproc *) |
|
1182 |
|
1183 text \<open>Cancellation of constant factors in comparisons (\<open><\<close> and \<open>\<le>\<close>)\<close> |
|
1184 |
|
1185 lemmas mult_less_cancel_left_numeral [simp, no_atp] = mult_less_cancel_left [of "numeral v"] for v |
|
1186 lemmas mult_less_cancel_right_numeral [simp, no_atp] = mult_less_cancel_right [of _ "numeral v"] for v |
|
1187 lemmas mult_le_cancel_left_numeral [simp, no_atp] = mult_le_cancel_left [of "numeral v"] for v |
|
1188 lemmas mult_le_cancel_right_numeral [simp, no_atp] = mult_le_cancel_right [of _ "numeral v"] for v |
|
1189 |
|
1190 text \<open>Multiplying out constant divisors in comparisons (\<open><\<close>, \<open>\<le>\<close> and \<open>=\<close>)\<close> |
|
1191 |
|
1192 named_theorems divide_const_simps "simplification rules to simplify comparisons involving constant divisors" |
|
1193 |
|
1194 lemmas le_divide_eq_numeral1 [simp,divide_const_simps] = |
|
1195 pos_le_divide_eq [of "numeral w", OF zero_less_numeral] |
|
1196 neg_le_divide_eq [of "- numeral w", OF neg_numeral_less_zero] for w |
|
1197 |
|
1198 lemmas divide_le_eq_numeral1 [simp,divide_const_simps] = |
|
1199 pos_divide_le_eq [of "numeral w", OF zero_less_numeral] |
|
1200 neg_divide_le_eq [of "- numeral w", OF neg_numeral_less_zero] for w |
|
1201 |
|
1202 lemmas less_divide_eq_numeral1 [simp,divide_const_simps] = |
|
1203 pos_less_divide_eq [of "numeral w", OF zero_less_numeral] |
|
1204 neg_less_divide_eq [of "- numeral w", OF neg_numeral_less_zero] for w |
|
1205 |
|
1206 lemmas divide_less_eq_numeral1 [simp,divide_const_simps] = |
|
1207 pos_divide_less_eq [of "numeral w", OF zero_less_numeral] |
|
1208 neg_divide_less_eq [of "- numeral w", OF neg_numeral_less_zero] for w |
|
1209 |
|
1210 lemmas eq_divide_eq_numeral1 [simp,divide_const_simps] = |
|
1211 eq_divide_eq [of _ _ "numeral w"] |
|
1212 eq_divide_eq [of _ _ "- numeral w"] for w |
|
1213 |
|
1214 lemmas divide_eq_eq_numeral1 [simp,divide_const_simps] = |
|
1215 divide_eq_eq [of _ "numeral w"] |
|
1216 divide_eq_eq [of _ "- numeral w"] for w |
|
1217 |
|
1218 |
|
1219 subsubsection \<open>Optional Simplification Rules Involving Constants\<close> |
|
1220 |
|
1221 text \<open>Simplify quotients that are compared with a literal constant.\<close> |
|
1222 |
|
1223 lemmas le_divide_eq_numeral [divide_const_simps] = |
|
1224 le_divide_eq [of "numeral w"] |
|
1225 le_divide_eq [of "- numeral w"] for w |
|
1226 |
|
1227 lemmas divide_le_eq_numeral [divide_const_simps] = |
|
1228 divide_le_eq [of _ _ "numeral w"] |
|
1229 divide_le_eq [of _ _ "- numeral w"] for w |
|
1230 |
|
1231 lemmas less_divide_eq_numeral [divide_const_simps] = |
|
1232 less_divide_eq [of "numeral w"] |
|
1233 less_divide_eq [of "- numeral w"] for w |
|
1234 |
|
1235 lemmas divide_less_eq_numeral [divide_const_simps] = |
|
1236 divide_less_eq [of _ _ "numeral w"] |
|
1237 divide_less_eq [of _ _ "- numeral w"] for w |
|
1238 |
|
1239 lemmas eq_divide_eq_numeral [divide_const_simps] = |
|
1240 eq_divide_eq [of "numeral w"] |
|
1241 eq_divide_eq [of "- numeral w"] for w |
|
1242 |
|
1243 lemmas divide_eq_eq_numeral [divide_const_simps] = |
|
1244 divide_eq_eq [of _ _ "numeral w"] |
|
1245 divide_eq_eq [of _ _ "- numeral w"] for w |
|
1246 |
|
1247 text \<open>Not good as automatic simprules because they cause case splits.\<close> |
|
1248 |
|
1249 lemmas [divide_const_simps] = |
|
1250 le_divide_eq_1 divide_le_eq_1 less_divide_eq_1 divide_less_eq_1 |
|
1251 |
1119 |
1252 |
1120 subsection \<open>Setting up simprocs\<close> |
1253 subsection \<open>Setting up simprocs\<close> |
1121 |
1254 |
1122 lemma mult_numeral_1: "Numeral1 * a = a" |
1255 lemma mult_numeral_1: "Numeral1 * a = a" |
1123 for a :: "'a::semiring_numeral" |
1256 for a :: "'a::semiring_numeral" |