2040 moreover have "degree (p - q) \<ge> card {x. poly (p - q) x = 0}" |
2040 moreover have "degree (p - q) \<ge> card {x. poly (p - q) x = 0}" |
2041 using neq by (intro card_poly_roots_bound) auto |
2041 using neq by (intro card_poly_roots_bound) auto |
2042 ultimately show False by linarith |
2042 ultimately show False by linarith |
2043 qed |
2043 qed |
2044 |
2044 |
|
2045 lemma poly_eqI_degree_lead_coeff: |
|
2046 fixes p q :: "'a :: {comm_ring_1, ring_no_zero_divisors} poly" |
|
2047 assumes "poly.coeff p n = poly.coeff q n" "card A \<ge> n" "degree p \<le> n" "degree q \<le> n" |
|
2048 assumes "\<And>z. z \<in> A \<Longrightarrow> poly p z = poly q z" |
|
2049 shows "p = q" |
|
2050 proof (rule ccontr) |
|
2051 assume "p \<noteq> q" |
|
2052 |
|
2053 have "n > 0" |
|
2054 proof (rule ccontr) |
|
2055 assume "\<not>(n > 0)" |
|
2056 thus False |
|
2057 using assms \<open>p \<noteq> q\<close> by (auto elim!: degree_eq_zeroE) |
|
2058 qed |
|
2059 |
|
2060 have "n \<le> card A" |
|
2061 by fact |
|
2062 also have "card A \<le> card {x. poly (p - q) x = 0}" |
|
2063 by (intro card_mono poly_roots_finite) (use \<open>p \<noteq> q\<close> assms in auto) |
|
2064 also have "card {x. poly (p - q) x = 0} \<le> degree (p - q)" |
|
2065 by (rule card_poly_roots_bound) (use \<open>p \<noteq> q\<close> in auto) |
|
2066 also have "degree (p - q) < n" |
|
2067 proof (intro degree_lessI allI impI) |
|
2068 fix k assume "k \<ge> n" |
|
2069 show "poly.coeff (p - q) k = 0" |
|
2070 proof (cases "k = n") |
|
2071 case False |
|
2072 hence "poly.coeff p k = 0" "poly.coeff q k = 0" |
|
2073 using assms \<open>k \<ge> n\<close> by (auto simp: coeff_eq_0) |
|
2074 thus ?thesis |
|
2075 by simp |
|
2076 qed (use assms in auto) |
|
2077 qed (use \<open>n > 0\<close> in auto) |
|
2078 finally show False |
|
2079 by simp |
|
2080 qed |
2045 |
2081 |
2046 |
2082 |
2047 subsubsection \<open>Order of polynomial roots\<close> |
2083 subsubsection \<open>Order of polynomial roots\<close> |
2048 |
2084 |
2049 definition order :: "'a::idom \<Rightarrow> 'a poly \<Rightarrow> nat" |
2085 definition order :: "'a::idom \<Rightarrow> 'a poly \<Rightarrow> nat" |