equal
deleted
inserted
replaced
1361 |
1361 |
1362 lemma Gcd_2 [simp]: "Gcd {a,b} = gcd a b" |
1362 lemma Gcd_2 [simp]: "Gcd {a,b} = gcd a b" |
1363 by (simp add: gcd_0) |
1363 by (simp add: gcd_0) |
1364 |
1364 |
1365 subclass semiring_gcd |
1365 subclass semiring_gcd |
1366 by unfold_locales (simp_all add: gcd_greatest_iff) |
1366 apply standard |
1367 |
1367 using gcd_right_idem |
|
1368 apply (simp_all add: lcm_gcd gcd_greatest_iff gcd_proj1_if_dvd) |
|
1369 done |
|
1370 |
|
1371 subclass semiring_Gcd |
|
1372 by standard (simp_all add: Gcd_greatest) |
|
1373 |
|
1374 subclass semiring_Lcm |
|
1375 by standard (simp add: Lcm_Gcd) |
|
1376 |
1368 end |
1377 end |
1369 |
1378 |
1370 text \<open> |
1379 text \<open> |
1371 A Euclidean ring is a Euclidean semiring with additive inverses. It provides a |
1380 A Euclidean ring is a Euclidean semiring with additive inverses. It provides a |
1372 few more lemmas; in particular, Bezout's lemma holds for any Euclidean ring. |
1381 few more lemmas; in particular, Bezout's lemma holds for any Euclidean ring. |
1380 subclass ring_gcd .. |
1389 subclass ring_gcd .. |
1381 |
1390 |
1382 lemma euclid_ext_gcd [simp]: |
1391 lemma euclid_ext_gcd [simp]: |
1383 "(case euclid_ext a b of (_, _ , t) \<Rightarrow> t) = gcd a b" |
1392 "(case euclid_ext a b of (_, _ , t) \<Rightarrow> t) = gcd a b" |
1384 by (induct a b rule: gcd_eucl_induct) |
1393 by (induct a b rule: gcd_eucl_induct) |
1385 (simp_all add: euclid_ext_0 gcd_0 euclid_ext_non_0 ac_simps split: prod.split prod.split_asm) |
1394 (simp_all add: euclid_ext_0 euclid_ext_non_0 ac_simps split: prod.split prod.split_asm) |
1386 |
1395 |
1387 lemma euclid_ext_gcd' [simp]: |
1396 lemma euclid_ext_gcd' [simp]: |
1388 "euclid_ext a b = (r, s, t) \<Longrightarrow> t = gcd a b" |
1397 "euclid_ext a b = (r, s, t) \<Longrightarrow> t = gcd a b" |
1389 by (insert euclid_ext_gcd[of a b], drule (1) subst, simp) |
1398 by (insert euclid_ext_gcd[of a b], drule (1) subst, simp) |
1390 |
1399 |
1451 begin |
1460 begin |
1452 |
1461 |
1453 definition [simp]: |
1462 definition [simp]: |
1454 "euclidean_size_nat = (id :: nat \<Rightarrow> nat)" |
1463 "euclidean_size_nat = (id :: nat \<Rightarrow> nat)" |
1455 |
1464 |
1456 definition [simp]: |
|
1457 "unit_factor_nat (n::nat) = (if n = 0 then 0 else 1 :: nat)" |
|
1458 |
|
1459 instance proof |
1465 instance proof |
1460 qed simp_all |
1466 qed simp_all |
1461 |
1467 |
1462 end |
1468 end |
1463 |
1469 |
1465 begin |
1471 begin |
1466 |
1472 |
1467 definition [simp]: |
1473 definition [simp]: |
1468 "euclidean_size_int = (nat \<circ> abs :: int \<Rightarrow> nat)" |
1474 "euclidean_size_int = (nat \<circ> abs :: int \<Rightarrow> nat)" |
1469 |
1475 |
1470 definition [simp]: |
|
1471 "unit_factor_int = (sgn :: int \<Rightarrow> int)" |
|
1472 |
|
1473 instance |
1476 instance |
1474 by standard (auto simp add: abs_mult nat_mult_distrib sgn_times split: abs_split) |
1477 by standard (auto simp add: abs_mult nat_mult_distrib split: abs_split) |
1475 |
1478 |
1476 end |
1479 end |
1477 |
1480 |
1478 instantiation poly :: (field) euclidean_ring |
1481 instantiation poly :: (field) euclidean_ring |
1479 begin |
1482 begin |