equal
deleted
inserted
replaced
3351 shows "algebraic x \<longleftrightarrow> (\<exists>p. (\<forall>i. coeff p i \<in> \<rat>) \<and> p \<noteq> 0 \<and> poly p x = 0)" |
3351 shows "algebraic x \<longleftrightarrow> (\<exists>p. (\<forall>i. coeff p i \<in> \<rat>) \<and> p \<noteq> 0 \<and> poly p x = 0)" |
3352 proof safe |
3352 proof safe |
3353 fix p assume rat: "\<forall>i. coeff p i \<in> \<rat>" and root: "poly p x = 0" and nz: "p \<noteq> 0" |
3353 fix p assume rat: "\<forall>i. coeff p i \<in> \<rat>" and root: "poly p x = 0" and nz: "p \<noteq> 0" |
3354 define cs where "cs = coeffs p" |
3354 define cs where "cs = coeffs p" |
3355 from rat have "\<forall>c\<in>range (coeff p). \<exists>c'. c = of_rat c'" unfolding Rats_def by blast |
3355 from rat have "\<forall>c\<in>range (coeff p). \<exists>c'. c = of_rat c'" unfolding Rats_def by blast |
3356 then obtain f where f: "\<And>i. coeff p i = of_rat (f (coeff p i))" |
3356 then obtain f where f: "coeff p i = of_rat (f (coeff p i))" for i |
3357 by (subst (asm) bchoice_iff) blast |
3357 by (subst (asm) bchoice_iff) blast |
3358 define cs' where "cs' = map (quotient_of \<circ> f) (coeffs p)" |
3358 define cs' where "cs' = map (quotient_of \<circ> f) (coeffs p)" |
3359 define d where "d = Lcm (set (map snd cs'))" |
3359 define d where "d = Lcm (set (map snd cs'))" |
3360 define p' where "p' = smult (of_int d) p" |
3360 define p' where "p' = smult (of_int d) p" |
3361 |
3361 |
3390 hence "d \<noteq> 0" unfolding d_def by (induction cs') simp_all |
3390 hence "d \<noteq> 0" unfolding d_def by (induction cs') simp_all |
3391 with nz have "p' \<noteq> 0" by (simp add: p'_def) |
3391 with nz have "p' \<noteq> 0" by (simp add: p'_def) |
3392 moreover from root have "poly p' x = 0" by (simp add: p'_def) |
3392 moreover from root have "poly p' x = 0" by (simp add: p'_def) |
3393 ultimately show "algebraic x" unfolding algebraic_def by blast |
3393 ultimately show "algebraic x" unfolding algebraic_def by blast |
3394 next |
3394 next |
3395 |
|
3396 assume "algebraic x" |
3395 assume "algebraic x" |
3397 then obtain p where p: "\<And>i. coeff p i \<in> \<int>" "poly p x = 0" "p \<noteq> 0" |
3396 then obtain p where p: "coeff p i \<in> \<int>" "poly p x = 0" "p \<noteq> 0" for i |
3398 by (force simp: algebraic_def) |
3397 by (force simp: algebraic_def) |
3399 moreover have "coeff p i \<in> \<int> \<Longrightarrow> coeff p i \<in> \<rat>" for i by (elim Ints_cases) simp |
3398 moreover have "coeff p i \<in> \<int> \<Longrightarrow> coeff p i \<in> \<rat>" for i by (elim Ints_cases) simp |
3400 ultimately show "(\<exists>p. (\<forall>i. coeff p i \<in> \<rat>) \<and> p \<noteq> 0 \<and> poly p x = 0)" by auto |
3399 ultimately show "(\<exists>p. (\<forall>i. coeff p i \<in> \<rat>) \<and> p \<noteq> 0 \<and> poly p x = 0)" by auto |
3401 qed |
3400 qed |
3402 |
3401 |