src/HOL/Power.thy
changeset 47255 30a1692557b0
parent 47241 243b33052e34
child 49824 c26665a197dc
equal deleted inserted replaced
47244:a7f85074c169 47255:30a1692557b0
    78   by (subst mult_commute) (simp add: power_mult)
    78   by (subst mult_commute) (simp add: power_mult)
    79 
    79 
    80 lemma power_odd_eq:
    80 lemma power_odd_eq:
    81   "a ^ Suc (2*n) = a * (a ^ n) ^ 2"
    81   "a ^ Suc (2*n) = a * (a ^ n) ^ 2"
    82   by (simp add: power_even_eq)
    82   by (simp add: power_even_eq)
       
    83 
       
    84 lemma power_numeral_even:
       
    85   "z ^ numeral (Num.Bit0 w) = (let w = z ^ (numeral w) in w * w)"
       
    86   unfolding numeral_Bit0 power_add Let_def ..
       
    87 
       
    88 lemma power_numeral_odd:
       
    89   "z ^ numeral (Num.Bit1 w) = (let w = z ^ (numeral w) in z * w * w)"
       
    90   unfolding numeral_Bit1 One_nat_def add_Suc_right add_0_right
       
    91   unfolding power_Suc power_add Let_def mult_assoc ..
    83 
    92 
    84 end
    93 end
    85 
    94 
    86 context comm_monoid_mult
    95 context comm_monoid_mult
    87 begin
    96 begin
   594 end
   603 end
   595 
   604 
   596 
   605 
   597 subsection {* Miscellaneous rules *}
   606 subsection {* Miscellaneous rules *}
   598 
   607 
       
   608 lemma power_eq_if: "p ^ m = (if m=0 then 1 else p * (p ^ (m - 1)))"
       
   609   unfolding One_nat_def by (cases m) simp_all
       
   610 
   599 lemma power2_sum:
   611 lemma power2_sum:
   600   fixes x y :: "'a::comm_semiring_1"
   612   fixes x y :: "'a::comm_semiring_1"
   601   shows "(x + y)\<twosuperior> = x\<twosuperior> + y\<twosuperior> + 2 * x * y"
   613   shows "(x + y)\<twosuperior> = x\<twosuperior> + y\<twosuperior> + 2 * x * y"
   602   by (simp add: algebra_simps power2_eq_square mult_2_right)
   614   by (simp add: algebra_simps power2_eq_square mult_2_right)
   603 
   615 
   644 apply (cases "b = 0")
   656 apply (cases "b = 0")
   645 apply (simp add: power_0_left)
   657 apply (simp add: power_0_left)
   646 apply (rule nonzero_power_divide)
   658 apply (rule nonzero_power_divide)
   647 apply assumption
   659 apply assumption
   648 done
   660 done
       
   661 
       
   662 text {* Simprules for comparisons where common factors can be cancelled. *}
       
   663 
       
   664 lemmas zero_compare_simps =
       
   665     add_strict_increasing add_strict_increasing2 add_increasing
       
   666     zero_le_mult_iff zero_le_divide_iff 
       
   667     zero_less_mult_iff zero_less_divide_iff 
       
   668     mult_le_0_iff divide_le_0_iff 
       
   669     mult_less_0_iff divide_less_0_iff 
       
   670     zero_le_power2 power2_less_0
   649 
   671 
   650 
   672 
   651 subsection {* Exponentiation for the Natural Numbers *}
   673 subsection {* Exponentiation for the Natural Numbers *}
   652 
   674 
   653 lemma nat_one_le_power [simp]:
   675 lemma nat_one_le_power [simp]: