This instance will be upgraded to Heptapod 0.31.0rc on 2022-05-19 at 11:00 UTC+2 (a few minutes of down time)

Commit c05ee65b by Manuel Eberl

parent 8b6582b73697
 ... ... @@ -535,7 +535,7 @@ proof (cases "p=0") qed auto lemma degree_of_gcd: "degree (gcd q r) \ 0 \ degree (gcd (of_int_poly q :: 'a :: {field_char_0,euclidean_ring_gcd} poly) (of_int_poly r)) \ 0" degree (gcd (of_int_poly q :: 'a :: {field_char_0, field_gcd} poly) (of_int_poly r)) \ 0" proof - let ?r = "of_rat :: rat \ 'a" interpret rpoly: field_hom' ?r ... ... @@ -598,7 +598,7 @@ end lemma factors_of_int_poly: defines "rp \ ipoly :: int poly \ 'a :: {euclidean_ring_gcd,field_char_0} \ 'a" defines "rp \ ipoly :: int poly \ 'a :: {field_gcd,field_char_0} \ 'a" assumes "factors_of_int_poly p = qs" shows "\ q. q \ set qs \ irreducible q \ lead_coeff q > 0 \ degree q \ degree p \ degree q \ 0" "p \ 0 \ rp p x = 0 \ (\ q \ set qs. rp q x = 0)" ... ... @@ -696,7 +696,7 @@ proof - qed lemma factors_int_poly_represents: fixes x :: "'a :: {field_char_0,euclidean_ring_gcd}" fixes x :: "'a :: {field_char_0,field_gcd}" assumes p: "p represents x" shows "\ q \ set (factors_of_int_poly p). q represents x \ irreducible q \ lead_coeff q > 0 \ degree q \ degree p" ... ... @@ -803,7 +803,7 @@ proof - then show ?thesis by (auto intro: exI[of _ ?p] simp: cf_pos_def) qed lemma gcd_of_int_poly: "gcd (of_int_poly f) (of_int_poly g :: 'a :: {field_char_0,euclidean_ring_gcd} poly) = lemma gcd_of_int_poly: "gcd (of_int_poly f) (of_int_poly g :: 'a :: {field_char_0,field_gcd} poly) = smult (inverse (of_int (lead_coeff (gcd f g)))) (of_int_poly (gcd f g))" proof - let ?ia = "of_int_poly :: _ \ 'a poly" ... ... @@ -817,7 +817,7 @@ proof - qed lemma algebraic_imp_represents_unique: fixes x :: "'a :: {field_char_0,euclidean_ring_gcd}" fixes x :: "'a :: {field_char_0,field_gcd}" assumes "algebraic x" shows "\! p. p represents x \ irreducible p \ lead_coeff p > 0" (is "Ex1 ?p") proof - ... ... @@ -852,7 +852,7 @@ proof - qed corollary irreducible_represents_imp_degree: fixes x :: "'a :: {field_char_0,euclidean_ring_gcd}" fixes x :: "'a :: {field_char_0,field_gcd}" assumes "irreducible f" and "f represents x" and "g represents x" shows "degree f \ degree g" proof - ... ... @@ -1236,7 +1236,7 @@ lemma sgn_ipoly_add_rat[simp]: lemma irreducible_preservation: fixes x :: "'a :: {field_char_0,euclidean_ring_gcd}" fixes x :: "'a :: {field_char_0,field_gcd}" assumes irr: "irreducible p" and x: "p represents x" and y: "q represents y" ... ... @@ -1307,7 +1307,7 @@ proof- qed lemma reflect_poly_irreducible: fixes x :: "'a :: {field_char_0,euclidean_ring_gcd}" fixes x :: "'a :: {field_char_0,field_gcd}" assumes p: "irreducible p" and x: "p represents x" and x0: "x \ 0" shows "irreducible (reflect_poly p)" proof - ... ...
 ... ... @@ -137,7 +137,7 @@ lemma of_rat_of_int_poly: "map_poly of_rat (of_int_poly p) = of_int_poly p" by (subst map_poly_map_poly, auto simp: o_def) lemma square_free_of_int_poly: assumes "square_free p" shows "square_free (of_int_poly p :: 'a :: {euclidean_ring_gcd, field_char_0} poly)" shows "square_free (of_int_poly p :: 'a :: {field_gcd, field_char_0} poly)" proof - have "square_free (map_poly of_rat (of_int_poly p) :: 'a poly)" unfolding of_rat_hom.square_free_map_poly by (rule square_free_int_rat[OF assms]) ... ...
 ... ... @@ -194,7 +194,7 @@ lemma euclid_ext_i [transfer_rule]: end locale field_ops = idom_divide_ops ops R + euclidean_semiring_ops ops R for ops :: "'i arith_ops_record" and R :: "'i \ 'a :: {field, normalization_euclidean_semiring, euclidean_ring, factorial_ring_gcd} \ bool" + R :: "'i \ 'a :: {field_gcd} \ bool" + assumes inverse[transfer_rule]: "(R ===> R) inverse Fields.inverse" ... ...
 ... ... @@ -315,16 +315,16 @@ next from p_dvd_q obtain k where q: "q = k * p" unfolding dvd_def by (auto simp: ac_simps) with q0 have "k \ 0" by auto then have "degree k = 0" using associatedD2 n p0 q by (metis (no_types, lifting) mult_cancel_right1 normalize_eq_0_iff normalize_mult poly_dvd_1) using degree_eq degree_mult_eq p0 q by fastforce then obtain c where k: "k = [: c :]" by (metis degree_0_id) with \k \ 0\ have "c \ 0" by auto have "q = smult c p" unfolding q k by simp with \c \ 0\ show ?thesis by auto qed lemma prod_list_normalize: "normalize (prod_list P) = prod_list (map normalize P)" lemma prod_list_normalize: fixes P :: "'b :: {idom_divide,normalization_semidom_multiplicative} poly list" shows "normalize (prod_list P) = prod_list (map normalize P)" proof (induct P) case Nil show ?case by auto ... ... @@ -361,7 +361,7 @@ end lemma gcd_monic_constant: "gcd f g \ {1, f}" if "monic f" and "degree g = 0" for f g :: "'a :: {field,euclidean_ring_gcd} poly" for f g :: "'a :: {field_gcd} poly" proof (cases "g = 0") case True moreover from \monic f\ have "normalize f = f" ... ... @@ -415,7 +415,7 @@ lemma power_poly_f_mod_binary: "power_poly_f_mod m a n = (if n = 0 then 1 mod m else let (d, r) = Divides.divmod_nat n 2; rec = power_poly_f_mod m ((a * a) mod m) d in if r = 0 then rec else (rec * a) mod m)" for m a :: "'a :: {factorial_ring_gcd, field} poly" for m a :: "'a :: {field_gcd} poly" proof - note d = power_poly_f_mod_def show ?thesis ... ... @@ -706,7 +706,7 @@ proof - qed lemma monic_prod_gcd: assumes f: "finite A" and f0: "(f :: 'b :: {field,factorial_ring_gcd} poly) \ 0" assumes f: "finite A" and f0: "(f :: 'b :: {field_gcd} poly) \ 0" shows "monic (\c\A. gcd f (h - [:c:]))" using f proof (induct A) ... ... @@ -754,7 +754,7 @@ qed auto lemma coprime_polynomial_factorization: fixes a1 :: "'b :: {field,factorial_ring_gcd} poly" fixes a1 :: "'b :: {field_gcd} poly" assumes irr: "as \ {q. irreducible q \ monic q}" and "finite as" and a1: "a1 \ as" and a2: "a2 \ as" and a1_not_a2: "a1 \ a2" shows "coprime a1 a2" ... ... @@ -1589,7 +1589,7 @@ by (rule exI[of _ 0], rule exI[of _ 1], auto) lemma coprime_cong_mult_factorization_poly: fixes f::"'b::{field} poly" and a b p :: "'c :: {factorial_ring_gcd,field} poly" and a b p :: "'c :: {field_gcd} poly" assumes finite_P: "finite P" and P: "P \ {q. irreducible q}" and p: "\p\P. [a=b] (mod p)" ... ... @@ -2723,7 +2723,8 @@ qed end lemma not_irreducible_factor_yields_prime_factors: assumes uf: "u dvd (f :: 'b :: {field,euclidean_ring_gcd} poly)" and fin: "finite P" and fP: "f = \P" and P: "P \ {q. irreducible q \ monic q}" assumes uf: "u dvd (f :: 'b :: {field_gcd} poly)" and fin: "finite P" and fP: "f = \P" and P: "P \ {q. irreducible q \ monic q}" and u: "degree u > 0" "\ irreducible u" shows "\ pi pj. pi \ P \ pj \ P \ pi \ pj \ pi dvd u \ pj dvd u" proof - ... ...
 ... ... @@ -16,28 +16,28 @@ imports begin lemma cong_add_poly: "[(a::'b::{factorial_ring_gcd,field} poly) = b] (mod m) \ [c = d] (mod m) \ [a + c = b + d] (mod m)" "[(a::'b::{field_gcd} poly) = b] (mod m) \ [c = d] (mod m) \ [a + c = b + d] (mod m)" by (fact cong_add) lemma cong_mult_poly: "[(a::'b::{field, factorial_ring_gcd} poly) = b] (mod m) \ [c = d] (mod m) \ [a * c = b * d] (mod m)" "[(a::'b::{field_gcd} poly) = b] (mod m) \ [c = d] (mod m) \ [a * c = b * d] (mod m)" by (fact cong_mult) lemma cong_mult_self_poly: "[(a::'b::{factorial_ring_gcd,field} poly) * m = 0] (mod m)" lemma cong_mult_self_poly: "[(a::'b::{field_gcd} poly) * m = 0] (mod m)" by (fact cong_mult_self_right) lemma cong_scalar2_poly: "[(a::'b::{field, factorial_ring_gcd} poly)= b] (mod m) \ [k * a = k * b] (mod m)" lemma cong_scalar2_poly: "[(a::'b::{field_gcd} poly)= b] (mod m) \ [k * a = k * b] (mod m)" by (fact cong_scalar_left) lemma cong_sum_poly: "(\x. x \ A \ [((f x)::'b::{factorial_ring_gcd,field} poly) = g x] (mod m)) \ "(\x. x \ A \ [((f x)::'b::{field_gcd} poly) = g x] (mod m)) \ [(\x\A. f x) = (\x\A. g x)] (mod m)" by (rule cong_sum) lemma cong_iff_lin_poly: "([(a::'b::{factorial_ring_gcd,field} poly) = b] (mod m)) = (\k. b = a + m * k)" lemma cong_iff_lin_poly: "([(a::'b::{field_gcd} poly) = b] (mod m)) = (\k. b = a + m * k)" using cong_diff_iff_cong_0 [of b a m] by (auto simp add: cong_0_iff dvd_def algebra_simps dest: cong_sym) lemma cong_solve_poly: "(a::'b::{normalization_euclidean_semiring, factorial_ring_gcd,field} poly) \ 0 \ \x. [a * x = gcd a n] (mod n)" lemma cong_solve_poly: "(a::'b::{field_gcd} poly) \ 0 \ \x. [a * x = gcd a n] (mod n)" proof (cases "n = 0") case True note n0=True ... ... @@ -63,7 +63,7 @@ qed lemma cong_solve_coprime_poly: assumes coprime_an:"coprime (a::'b::{normalization_euclidean_semiring, factorial_ring_gcd,field} poly) n" assumes coprime_an:"coprime (a::'b::{field_gcd} poly) n" shows "\x. [a * x = 1] (mod n)" proof (cases "a = 0") case True ... ... @@ -78,12 +78,12 @@ next qed lemma cong_dvd_modulus_poly: "[x = y] (mod m) \ n dvd m \ [x = y] (mod n)" for x y :: "'b::{factorial_ring_gcd,field} poly" "[x = y] (mod m) \ n dvd m \ [x = y] (mod n)" for x y :: "'b::{field_gcd} poly" by (auto simp add: cong_iff_lin_poly elim!: dvdE) lemma chinese_remainder_aux_poly: fixes A :: "'a set" and m :: "'a \ 'b::{normalization_euclidean_semiring,factorial_ring_gcd,field} poly" and m :: "'a \ 'b::{field_gcd} poly" assumes fin: "finite A" and cop: "\i \ A. (\j \ A. i \ j \ coprime (m i) (m j))" shows "\b. (\i \ A. [b i = 1] (mod m i) \ [b i = 0] (mod (\j \ A - {i}. m j)))" ... ... @@ -108,7 +108,7 @@ qed (*The Chinese Remainder Theorem for polynomials: *) lemma chinese_remainder_poly: fixes A :: "'a set" and m :: "'a \ 'b::{normalization_euclidean_semiring,factorial_ring_gcd,field} poly" and m :: "'a \ 'b::{field_gcd} poly" and u :: "'a \ 'b poly" assumes fin: "finite A" and cop: "\i\A. (\j\A. i \ j \ coprime (m i) (m j))" ... ... @@ -157,27 +157,27 @@ qed (*********************** Now we try to prove the uniqueness **********************) lemma cong_trans_poly: "[(a::'b::{factorial_ring_gcd,field} poly) = b] (mod m) \ [b = c] (mod m) \ [a = c] (mod m)" "[(a::'b::{field_gcd} poly) = b] (mod m) \ [b = c] (mod m) \ [a = c] (mod m)" by (fact cong_trans) lemma cong_mod_poly: "(n::'b::{factorial_ring_gcd,field} poly) ~= 0 \ [a mod n = a] (mod n)" lemma cong_mod_poly: "(n::'b::{field_gcd} poly) ~= 0 \ [a mod n = a] (mod n)" by auto lemma cong_sym_poly: "[(a::'b::{factorial_ring_gcd,field} poly) = b] (mod m) \ [b = a] (mod m)" lemma cong_sym_poly: "[(a::'b::{field_gcd} poly) = b] (mod m) \ [b = a] (mod m)" by (fact cong_sym) lemma cong_1_poly: "[(a::'b::{factorial_ring_gcd,field} poly) = b] (mod 1)" lemma cong_1_poly: "[(a::'b::{field_gcd} poly) = b] (mod 1)" by (fact cong_1) lemma coprime_cong_mult_poly: assumes "[(a::'b::{factorial_ring_gcd,field} poly) = b] (mod m)" and "[a = b] (mod n)" and "coprime m n" assumes "[(a::'b::{field_gcd} poly) = b] (mod m)" and "[a = b] (mod n)" and "coprime m n" shows "[a = b] (mod m * n)" using divides_mult assms by (metis (no_types, hide_lams) cong_dvd_modulus_poly cong_iff_lin_poly dvd_mult2 dvd_refl minus_add_cancel mult.right_neutral) lemma coprime_cong_prod_poly: "(\i\A. (\j\A. i \ j \ coprime (m i) (m j))) \ (\i\A. [(x::'b::{factorial_ring_gcd,field} poly) = y] (mod m i)) \ (\i\A. [(x::'b::{field_gcd} poly) = y] (mod m i)) \ [x = y] (mod (\i\A. m i))" apply (induct A rule: infinite_finite_induct) apply auto ... ... @@ -185,13 +185,13 @@ lemma coprime_cong_prod_poly: done lemma cong_less_modulus_unique_poly: "[(x::'b::{factorial_ring_gcd,field} poly) = y] (mod m) \ degree x < degree m \ degree y < degree m \ x = y" "[(x::'b::{field_gcd} poly) = y] (mod m) \ degree x < degree m \ degree y < degree m \ x = y" by (simp add: cong_def mod_poly_less) lemma chinese_remainder_unique_poly: fixes A :: "'a set" and m :: "'a \ 'b::{normalization_euclidean_semiring,factorial_ring_gcd,field} poly" and m :: "'a \ 'b::{field_gcd} poly" and u :: "'a \ 'b poly" assumes nz: "\i\A. (m i) \ 0" and cop: "\i\A. (\j\A. i \ j \ coprime (m i) (m j))" ... ...
 ... ... @@ -19,7 +19,8 @@ declare [[code abort: dummy_Gcd]] lemma dummy_Gcd_Lcm: "Gcd x = dummy_Gcd x" "Lcm x = dummy_Lcm x" unfolding dummy_Gcd_def dummy_Lcm_def by auto lemmas dummy_Gcd_Lcm_poly [code] = dummy_Gcd_Lcm [where ?'a = "'a :: factorial_ring_gcd poly"] lemmas dummy_Gcd_Lcm_poly [code] = dummy_Gcd_Lcm [where ?'a = "'a :: {factorial_ring_gcd,semiring_gcd_mult_normalize} poly"] lemmas dummy_Gcd_Lcm_int [code] = dummy_Gcd_Lcm [where ?'a = int] lemmas dummy_Gcd_Lcm_nat [code] = dummy_Gcd_Lcm [where ?'a = nat] ... ...
 ... ... @@ -224,7 +224,7 @@ proof (intro allI conjI impI notI) from sf[OF _ this] 0 nzq show False by simp qed lemma gcd_reflect_poly: fixes f :: "'a :: factorial_ring_gcd poly" lemma gcd_reflect_poly: fixes f :: "'a :: {factorial_ring_gcd, semiring_gcd_mult_normalize} poly" assumes nz: "coeff f 0 \ 0" "coeff g 0 \ 0" shows "gcd (reflect_poly f) (reflect_poly g) = normalize (reflect_poly (gcd f g))" proof (rule sym, rule gcdI) ... ...
 ... ... @@ -14,7 +14,8 @@ imports begin (*TODO: Move*) interpretation content_hom: monoid_mult_hom "content::'a::factorial_semiring_gcd poly \ _" interpretation content_hom: monoid_mult_hom "content::'a::{factorial_semiring, semiring_gcd, normalization_semidom_multiplicative} poly \ _" by (unfold_locales, auto simp: content_mult) lemma prod_dvd_1_imp_all_dvd_1: ... ...
 ... ... @@ -320,6 +320,19 @@ definition Lcm_mod_ring :: "'a mod_ring set \ 'a mod_ring" where "Lc instance by (intro_classes, auto simp: gcd_mod_ring_def lcm_mod_ring_def Gcd_mod_ring_def Lcm_mod_ring_def) end instantiation mod_ring :: (prime_card) unique_euclidean_ring begin definition [simp]: "division_segment_mod_ring (x :: 'a mod_ring) = (1 :: 'a mod_ring)" instance by intro_classes (auto simp: euclidean_size_mod_ring_def split: if_splits) end instance mod_ring :: (prime_card) field_gcd by intro_classes auto lemma surj_of_nat_mod_ring: "\ i. i < CARD('a :: prime_card) \ (x :: 'a mod_ring) = of_nat i" by (rule exI[of _ "nat (to_int_mod_ring x)"], unfold of_nat_of_int_mod_ring o_def, subst nat_0_le, transfer, simp, simp, transfer, auto) ... ...
 ... ... @@ -25,7 +25,7 @@ begin lemma uniqueness_poly_equality: fixes f g :: "'a :: factorial_ring_gcd poly" fixes f g :: "'a :: {factorial_ring_gcd,semiring_gcd_mult_normalize} poly" assumes cop: "coprime f g" and deg: "B = 0 \ degree B < degree f" "B' = 0 \ degree B' < degree f" and f: "f \ 0" and eq: "A * f + B * g = A' * f + B' * g" ... ... @@ -89,7 +89,7 @@ proof - show "B = 0 \ degree B < degree D" using deg unfolding B . qed lemma dupe_monic_unique: fixes D :: "'a :: factorial_ring_gcd poly" lemma dupe_monic_unique: fixes D :: "'a :: {factorial_ring_gcd,semiring_gcd_mult_normalize} poly" assumes 1: "D*S + H*T = 1" and mon: "monic D" and dupe: "dupe_monic D H S T U = (A,B)" ... ...
 ... ... @@ -91,7 +91,7 @@ lemma yun_wrel_minus: assumes "yun_wrel F c f" "yun_wrel G c g" using assms unfolding yun_wrel_def by (auto simp: smult_diff_right hom_distribs) lemma gcd_smult_left: assumes "c \ 0" shows "gcd (smult c f) g = gcd f (g :: 'b :: {field, factorial_ring_gcd} poly)" shows "gcd (smult c f) g = gcd f (g :: 'b :: {field_gcd} poly)" proof - from assms have "normalize c = 1" by (meson dvd_field_iff is_unit_normalize) ... ... @@ -99,7 +99,7 @@ proof - by (metis (no_types) Polynomial.normalize_smult gcd.commute gcd.left_commute gcd_left_idem gcd_self smult_1_left) qed lemma gcd_smult_right: "c \ 0 \ gcd f (smult c g) = gcd f (g :: 'b :: {field, factorial_ring_gcd} poly)" lemma gcd_smult_right: "c \ 0 \ gcd f (smult c g) = gcd f (g :: 'b :: {field_gcd} poly)" using gcd_smult_left[of c g f] by (simp add: gcd.commute) lemma gcd_rat_to_gcd_int: "gcd (of_int_poly f :: rat poly) (of_int_poly g) = ... ...