1359 |
1359 |
1360 instantiation fps :: (field) euclidean_ring |
1360 instantiation fps :: (field) euclidean_ring |
1361 begin |
1361 begin |
1362 |
1362 |
1363 definition fps_euclidean_size_def: |
1363 definition fps_euclidean_size_def: |
1364 "euclidean_size f = (if f = 0 then 0 else Suc (subdegree f))" |
1364 "euclidean_size f = (if f = 0 then 0 else 2 ^ subdegree f)" |
1365 |
1365 |
1366 instance proof |
1366 instance proof |
1367 fix f g :: "'a fps" assume [simp]: "g \<noteq> 0" |
1367 fix f g :: "'a fps" assume [simp]: "g \<noteq> 0" |
1368 show "euclidean_size f \<le> euclidean_size (f * g)" |
1368 show "euclidean_size f \<le> euclidean_size (f * g)" |
1369 by (cases "f = 0") (auto simp: fps_euclidean_size_def) |
1369 by (cases "f = 0") (auto simp: fps_euclidean_size_def) |
1370 show "euclidean_size (f mod g) < euclidean_size g" |
1370 show "euclidean_size (f mod g) < euclidean_size g" |
1371 apply (cases "f = 0", simp add: fps_euclidean_size_def) |
1371 apply (cases "f = 0", simp add: fps_euclidean_size_def) |
1372 apply (rule disjE[OF le_less_linear[of "subdegree g" "subdegree f"]]) |
1372 apply (rule disjE[OF le_less_linear[of "subdegree g" "subdegree f"]]) |
1373 apply (simp_all add: fps_mod_eq_zero fps_euclidean_size_def subdegree_mod) |
1373 apply (simp_all add: fps_mod_eq_zero fps_euclidean_size_def subdegree_mod) |
1374 done |
1374 done |
1375 qed |
1375 qed (simp_all add: fps_euclidean_size_def) |
1376 |
1376 |
1377 end |
1377 end |
1378 |
1378 |
1379 instantiation fps :: (field) euclidean_ring_gcd |
1379 instantiation fps :: (field) euclidean_ring_gcd |
1380 begin |
1380 begin |
1381 definition fps_gcd_def: "(gcd :: 'a fps \<Rightarrow> _) = gcd_eucl" |
1381 definition fps_gcd_def: "(gcd :: 'a fps \<Rightarrow> _) = gcd_eucl" |
1382 definition fps_lcm_def: "(lcm :: 'a fps \<Rightarrow> _) = lcm_eucl" |
1382 definition fps_lcm_def: "(lcm :: 'a fps \<Rightarrow> _) = lcm_eucl" |
1383 definition fps_Gcd_def: "(Gcd :: 'a fps set \<Rightarrow> _) = Gcd_eucl" |
1383 definition fps_Gcd_def: "(Gcd :: 'a fps set \<Rightarrow> _) = Gcd_eucl" |
1384 definition fps_Lcm_def: "(Lcm :: 'a fps set \<Rightarrow> _) = Lcm_eucl" |
1384 definition fps_Lcm_def: "(Lcm :: 'a fps set \<Rightarrow> _) = Lcm_eucl" |
1385 instance by intro_classes (simp_all add: fps_gcd_def fps_lcm_def fps_Gcd_def fps_Lcm_def) |
1385 instance by standard (simp_all add: fps_gcd_def fps_lcm_def fps_Gcd_def fps_Lcm_def) |
1386 end |
1386 end |
1387 |
1387 |
1388 lemma fps_gcd: |
1388 lemma fps_gcd: |
1389 assumes [simp]: "f \<noteq> 0" "g \<noteq> 0" |
1389 assumes [simp]: "f \<noteq> 0" "g \<noteq> 0" |
1390 shows "gcd f g = X ^ min (subdegree f) (subdegree g)" |
1390 shows "gcd f g = X ^ min (subdegree f) (subdegree g)" |
1471 proof (rule ccontr) |
1471 proof (rule ccontr) |
1472 assume "Lcm A \<noteq> 0" |
1472 assume "Lcm A \<noteq> 0" |
1473 from unbounded obtain f where f: "f \<in> A" "subdegree (Lcm A) < subdegree f" |
1473 from unbounded obtain f where f: "f \<in> A" "subdegree (Lcm A) < subdegree f" |
1474 unfolding bdd_above_def by (auto simp: not_le) |
1474 unfolding bdd_above_def by (auto simp: not_le) |
1475 moreover from this and \<open>Lcm A \<noteq> 0\<close> have "subdegree f \<le> subdegree (Lcm A)" |
1475 moreover from this and \<open>Lcm A \<noteq> 0\<close> have "subdegree f \<le> subdegree (Lcm A)" |
1476 by (intro dvd_imp_subdegree_le) simp_all |
1476 by (intro dvd_imp_subdegree_le dvd_Lcm) simp_all |
1477 ultimately show False by simp |
1477 ultimately show False by simp |
1478 qed |
1478 qed |
1479 with unbounded show ?thesis by simp |
1479 with unbounded show ?thesis by simp |
1480 qed (simp_all add: fps_Lcm) |
1480 qed (simp_all add: fps_Lcm Lcm_eq_0_I) |
|
1481 |
1481 |
1482 |
1482 |
1483 |
1483 subsection \<open>Formal Derivatives, and the MacLaurin theorem around 0\<close> |
1484 subsection \<open>Formal Derivatives, and the MacLaurin theorem around 0\<close> |
1484 |
1485 |
1485 definition "fps_deriv f = Abs_fps (\<lambda>n. of_nat (n + 1) * f $ (n + 1))" |
1486 definition "fps_deriv f = Abs_fps (\<lambda>n. of_nat (n + 1) * f $ (n + 1))" |
4252 by (simp add: ac_simps) |
4253 by (simp add: ac_simps) |
4253 |
4254 |
4254 |
4255 |
4255 subsection \<open>Hypergeometric series\<close> |
4256 subsection \<open>Hypergeometric series\<close> |
4256 |
4257 |
|
4258 (* TODO: Rename this *) |
4257 definition "F as bs (c::'a::{field_char_0,field}) = |
4259 definition "F as bs (c::'a::{field_char_0,field}) = |
4258 Abs_fps (\<lambda>n. (foldl (\<lambda>r a. r* pochhammer a n) 1 as * c^n) / |
4260 Abs_fps (\<lambda>n. (foldl (\<lambda>r a. r* pochhammer a n) 1 as * c^n) / |
4259 (foldl (\<lambda>r b. r * pochhammer b n) 1 bs * of_nat (fact n)))" |
4261 (foldl (\<lambda>r b. r * pochhammer b n) 1 bs * of_nat (fact n)))" |
4260 |
4262 |
4261 lemma F_nth[simp]: "F as bs c $ n = |
4263 lemma F_nth[simp]: "F as bs c $ n = |