equal
deleted
inserted
replaced
352 |
352 |
353 (* REVISIT: should this be generalized to all semiring_div types? *) |
353 (* REVISIT: should this be generalized to all semiring_div types? *) |
354 lemmas zmod_eq_0D [dest!] = zmod_eq_0_iff [THEN iffD1] |
354 lemmas zmod_eq_0D [dest!] = zmod_eq_0_iff [THEN iffD1] |
355 |
355 |
356 |
356 |
357 subsubsection \<open>Proving @{term "a div (b * c) = (a div b) div c"}\<close> |
357 subsubsection \<open>Proving \<^term>\<open>a div (b * c) = (a div b) div c\<close>\<close> |
358 |
358 |
359 (*The condition c>0 seems necessary. Consider that 7 div ~6 = ~2 but |
359 (*The condition c>0 seems necessary. Consider that 7 div ~6 = ~2 but |
360 7 div 2 div ~3 = 3 div ~3 = ~1. The subcase (a div b) mod c = 0 seems |
360 7 div 2 div ~3 = 3 div ~3 = ~1. The subcase (a div b) mod c = 0 seems |
361 to cause particular problems.*) |
361 to cause particular problems.*) |
362 |
362 |
493 then show ?thesis |
493 then show ?thesis |
494 unfolding linorder_neq_iff |
494 unfolding linorder_neq_iff |
495 by (auto simp add: split_pos_lemma [of concl: "\<lambda>x y. P y"] split_neg_lemma [of concl: "\<lambda>x y. P y"]) |
495 by (auto simp add: split_pos_lemma [of concl: "\<lambda>x y. P y"] split_neg_lemma [of concl: "\<lambda>x y. P y"]) |
496 qed auto |
496 qed auto |
497 |
497 |
498 text \<open>Enable (lin)arith to deal with @{const divide} and @{const modulo} |
498 text \<open>Enable (lin)arith to deal with \<^const>\<open>divide\<close> and \<^const>\<open>modulo\<close> |
499 when these are applied to some constant that is of the form |
499 when these are applied to some constant that is of the form |
500 @{term "numeral k"}:\<close> |
500 \<^term>\<open>numeral k\<close>:\<close> |
501 declare split_zdiv [of _ _ "numeral k", arith_split] for k |
501 declare split_zdiv [of _ _ "numeral k", arith_split] for k |
502 declare split_zmod [of _ _ "numeral k", arith_split] for k |
502 declare split_zmod [of _ _ "numeral k", arith_split] for k |
503 |
503 |
504 |
504 |
505 subsubsection \<open>Computing \<open>div\<close> and \<open>mod\<close> with shifting\<close> |
505 subsubsection \<open>Computing \<open>div\<close> and \<open>mod\<close> with shifting\<close> |
1255 "- numeral a div 1 :: int" | "- numeral a mod 1 :: int" | |
1255 "- numeral a div 1 :: int" | "- numeral a mod 1 :: int" | |
1256 "- numeral a div - 1 :: int" | "- numeral a mod - 1 :: int" | |
1256 "- numeral a div - 1 :: int" | "- numeral a mod - 1 :: int" | |
1257 "- numeral a div numeral b :: int" | "- numeral a mod numeral b :: int" | |
1257 "- numeral a div numeral b :: int" | "- numeral a mod numeral b :: int" | |
1258 "- numeral a div - numeral b :: int" | "- numeral a mod - numeral b :: int") = |
1258 "- numeral a div - numeral b :: int" | "- numeral a mod - numeral b :: int") = |
1259 \<open> let |
1259 \<open> let |
1260 val if_cong = the (Code.get_case_cong @{theory} @{const_name If}); |
1260 val if_cong = the (Code.get_case_cong \<^theory> \<^const_name>\<open>If\<close>); |
1261 fun successful_rewrite ctxt ct = |
1261 fun successful_rewrite ctxt ct = |
1262 let |
1262 let |
1263 val thm = Simplifier.rewrite ctxt ct |
1263 val thm = Simplifier.rewrite ctxt ct |
1264 in if Thm.is_reflexive thm then NONE else SOME thm end; |
1264 in if Thm.is_reflexive thm then NONE else SOME thm end; |
1265 in fn phi => |
1265 in fn phi => |