src/HOL/Int.thy
changeset 80948 572970d15ab0
parent 80932 261cd8722677
equal deleted inserted replaced
80947:1ba97eb5e5e2 80948:572970d15ab0
  1788   by (simp add: divide_inverse power_int_minus)
  1788   by (simp add: divide_inverse power_int_minus)
  1789 
  1789 
  1790 lemma power_int_eq_0_iff [simp]: "power_int (x::'a) n = 0 \<longleftrightarrow> x = 0 \<and> n \<noteq> 0"
  1790 lemma power_int_eq_0_iff [simp]: "power_int (x::'a) n = 0 \<longleftrightarrow> x = 0 \<and> n \<noteq> 0"
  1791   by (auto simp: power_int_def)
  1791   by (auto simp: power_int_def)
  1792 
  1792 
  1793 lemma power_int_0_left_If: "power_int (0 :: 'a) m = (if m = 0 then 1 else 0)"
  1793 lemma power_int_0_left_if: "power_int (0 :: 'a) m = (if m = 0 then 1 else 0)"
  1794   by (auto simp: power_int_def)
  1794   by (auto simp: power_int_def)
  1795 
  1795 
  1796 lemma power_int_0_left [simp]: "m \<noteq> 0 \<Longrightarrow> power_int (0 :: 'a) m = 0"
  1796 lemma power_int_0_left [simp]: "m \<noteq> 0 \<Longrightarrow> power_int (0 :: 'a) m = 0"
  1797   by (simp add: power_int_0_left_If)
  1797   by (simp add: power_int_0_left_if)
  1798 
  1798 
  1799 lemma power_int_1_left [simp]: "power_int 1 n = (1 :: 'a :: division_ring)"
  1799 lemma power_int_1_left [simp]: "power_int 1 n = (1 :: 'a :: division_ring)"
  1800   by (auto simp: power_int_def) 
  1800   by (auto simp: power_int_def) 
  1801 
  1801 
  1802 lemma power_diff_conv_inverse: "x \<noteq> 0 \<Longrightarrow> m \<le> n \<Longrightarrow> (x :: 'a) ^ (n - m) = x ^ n * inverse x ^ m"
  1802 lemma power_diff_conv_inverse: "x \<noteq> 0 \<Longrightarrow> m \<le> n \<Longrightarrow> (x :: 'a) ^ (n - m) = x ^ n * inverse x ^ m"
  1834 lemma power_int_add:
  1834 lemma power_int_add:
  1835   assumes "x \<noteq> 0 \<or> m + n \<noteq> 0"
  1835   assumes "x \<noteq> 0 \<or> m + n \<noteq> 0"
  1836   shows   "power_int (x::'a) (m + n) = power_int x m * power_int x n"
  1836   shows   "power_int (x::'a) (m + n) = power_int x m * power_int x n"
  1837 proof (cases "x = 0")
  1837 proof (cases "x = 0")
  1838   case True
  1838   case True
  1839   thus ?thesis using assms by (auto simp: power_int_0_left_If)
  1839   thus ?thesis using assms by (auto simp: power_int_0_left_if)
  1840 next
  1840 next
  1841   case [simp]: False
  1841   case [simp]: False
  1842   show ?thesis
  1842   show ?thesis
  1843   proof (cases m n rule: int_cases4[case_product int_cases4])
  1843   proof (cases m n rule: int_cases4[case_product int_cases4])
  1844     case (nonneg_nonneg a b)
  1844     case (nonneg_nonneg a b)
  2048   have "power_int a N = power_int a n * power_int a (N - n)"
  2048   have "power_int a N = power_int a n * power_int a (N - n)"
  2049     using assms False by (simp flip: power_int_add)
  2049     using assms False by (simp flip: power_int_add)
  2050   also have "\<dots> \<le> power_int a n * 1"
  2050   also have "\<dots> \<le> power_int a n * 1"
  2051     using assms * by (intro mult_left_mono) (auto simp: power_int_def)
  2051     using assms * by (intro mult_left_mono) (auto simp: power_int_def)
  2052   finally show ?thesis by simp
  2052   finally show ?thesis by simp
  2053 qed (use assms in \<open>auto simp: power_int_0_left_If\<close>)
  2053 qed (use assms in \<open>auto simp: power_int_0_left_if\<close>)
  2054 
  2054 
  2055 lemma one_less_power_int: "1 < (a :: 'a) \<Longrightarrow> 0 < n \<Longrightarrow> 1 < power_int a n"
  2055 lemma one_less_power_int: "1 < (a :: 'a) \<Longrightarrow> 0 < n \<Longrightarrow> 1 < power_int a n"
  2056   using power_int_strict_increasing[of 0 n a] by simp
  2056   using power_int_strict_increasing[of 0 n a] by simp
  2057 
  2057 
  2058 lemma power_int_abs: "\<bar>power_int a n :: 'a\<bar> = power_int \<bar>a\<bar> n"
  2058 lemma power_int_abs: "\<bar>power_int a n :: 'a\<bar> = power_int \<bar>a\<bar> n"