# HG changeset patch # User wenzelm # Date 1434742893 -7200 # Node ID fad653acf58f8ca3e037317ee49ee6d07e8f5613 # Parent 278b65d9339ce2b8ddf49218e47b32e50480dc1f isabelle update_cartouches; diff -r 278b65d9339c -r fad653acf58f src/HOL/Number_Theory/Cong.thy --- a/src/HOL/Number_Theory/Cong.thy Fri Jun 19 21:33:03 2015 +0200 +++ b/src/HOL/Number_Theory/Cong.thy Fri Jun 19 21:41:33 2015 +0200 @@ -23,13 +23,13 @@ natural numbers and the integers, and added a number of new theorems. *) -section {* Congruence *} +section \Congruence\ theory Cong imports Primes begin -subsection {* Turn off @{text One_nat_def} *} +subsection \Turn off @{text One_nat_def}\ lemma power_eq_one_eq_nat [simp]: "((x::nat)^m = 1) = (m = 0 | x = 1)" by (induct m) auto @@ -37,7 +37,7 @@ declare mod_pos_pos_trivial [simp] -subsection {* Main definitions *} +subsection \Main definitions\ class cong = fixes cong :: "'a \ 'a \ 'a \ bool" ("(1[_ = _] '(()mod _'))") @@ -74,7 +74,7 @@ end -subsection {* Set up Transfer *} +subsection \Set up Transfer\ lemma transfer_nat_int_cong: @@ -97,7 +97,7 @@ transfer_int_nat_cong] -subsection {* Congruence *} +subsection \Congruence\ (* was zcong_0, etc. *) lemma cong_0_nat [simp, presburger]: "([(a::nat) = b] (mod 0)) = (a = b)" @@ -633,20 +633,20 @@ have "[?x = u1 * 1 + u2 * 0] (mod m1)" apply (rule cong_add_nat) apply (rule cong_scalar2_nat) - apply (rule `[b1 = 1] (mod m1)`) + apply (rule \[b1 = 1] (mod m1)\) apply (rule cong_scalar2_nat) - apply (rule `[b2 = 0] (mod m1)`) + apply (rule \[b2 = 0] (mod m1)\) done then have "[?x = u1] (mod m1)" by simp have "[?x = u1 * 0 + u2 * 1] (mod m2)" apply (rule cong_add_nat) apply (rule cong_scalar2_nat) - apply (rule `[b1 = 0] (mod m2)`) + apply (rule \[b1 = 0] (mod m2)\) apply (rule cong_scalar2_nat) - apply (rule `[b2 = 1] (mod m2)`) + apply (rule \[b2 = 1] (mod m2)\) done then have "[?x = u2] (mod m2)" by simp - with `[?x = u1] (mod m1)` show ?thesis by blast + with \[?x = u1] (mod m1)\ show ?thesis by blast qed lemma binary_chinese_remainder_int: @@ -661,20 +661,20 @@ have "[?x = u1 * 1 + u2 * 0] (mod m1)" apply (rule cong_add_int) apply (rule cong_scalar2_int) - apply (rule `[b1 = 1] (mod m1)`) + apply (rule \[b1 = 1] (mod m1)\) apply (rule cong_scalar2_int) - apply (rule `[b2 = 0] (mod m1)`) + apply (rule \[b2 = 0] (mod m1)\) done then have "[?x = u1] (mod m1)" by simp have "[?x = u1 * 0 + u2 * 1] (mod m2)" apply (rule cong_add_int) apply (rule cong_scalar2_int) - apply (rule `[b1 = 0] (mod m2)`) + apply (rule \[b1 = 0] (mod m2)\) apply (rule cong_scalar2_int) - apply (rule `[b2 = 1] (mod m2)`) + apply (rule \[b2 = 1] (mod m2)\) done then have "[?x = u2] (mod m2)" by simp - with `[?x = u1] (mod m1)` show ?thesis by blast + with \[?x = u1] (mod m1)\ show ?thesis by blast qed lemma cong_modulus_mult_nat: "[(x::nat) = y] (mod m * n) \ @@ -712,7 +712,7 @@ have one: "[?x = u1] (mod m1)" apply (rule cong_trans_nat) prefer 2 - apply (rule `[y = u1] (mod m1)`) + apply (rule \[y = u1] (mod m1)\) apply (rule cong_modulus_mult_nat) apply (rule cong_mod_nat) using nz apply auto @@ -720,7 +720,7 @@ have two: "[?x = u2] (mod m2)" apply (rule cong_trans_nat) prefer 2 - apply (rule `[y = u2] (mod m2)`) + apply (rule \[y = u2] (mod m2)\) apply (subst mult.commute) apply (rule cong_modulus_mult_nat) apply (rule cong_mod_nat) @@ -733,19 +733,19 @@ assume "[z = u1] (mod m1)" and "[z = u2] (mod m2)" have "[?x = z] (mod m1)" apply (rule cong_trans_nat) - apply (rule `[?x = u1] (mod m1)`) + apply (rule \[?x = u1] (mod m1)\) apply (rule cong_sym_nat) - apply (rule `[z = u1] (mod m1)`) + apply (rule \[z = u1] (mod m1)\) done moreover have "[?x = z] (mod m2)" apply (rule cong_trans_nat) - apply (rule `[?x = u2] (mod m2)`) + apply (rule \[?x = u2] (mod m2)\) apply (rule cong_sym_nat) - apply (rule `[z = u2] (mod m2)`) + apply (rule \[z = u2] (mod m2)\) done ultimately have "[?x = z] (mod m1 * m2)" by (auto intro: coprime_cong_mult_nat a) - with `z < m1 * m2` `?x < m1 * m2` show "z = ?x" + with \z < m1 * m2\ \?x < m1 * m2\ show "z = ?x" apply (intro cong_less_modulus_unique_nat) apply (auto, erule cong_sym_nat) done diff -r 278b65d9339c -r fad653acf58f src/HOL/Number_Theory/Eratosthenes.thy --- a/src/HOL/Number_Theory/Eratosthenes.thy Fri Jun 19 21:33:03 2015 +0200 +++ b/src/HOL/Number_Theory/Eratosthenes.thy Fri Jun 19 21:41:33 2015 +0200 @@ -2,14 +2,14 @@ Author: Florian Haftmann, TU Muenchen *) -section {* The sieve of Eratosthenes *} +section \The sieve of Eratosthenes\ theory Eratosthenes imports Main Primes begin -subsection {* Preliminary: strict divisibility *} +subsection \Preliminary: strict divisibility\ context dvd begin @@ -20,9 +20,9 @@ end -subsection {* Main corpus *} +subsection \Main corpus\ -text {* The sieve is modelled as a list of booleans, where @{const False} means \emph{marked out}. *} +text \The sieve is modelled as a list of booleans, where @{const False} means \emph{marked out}.\ type_synonym marks = "bool list" @@ -58,7 +58,7 @@ intro!: sorted_filter distinct_filter inj_onI sorted_distinct_set_unique) -text {* Marking out multiples in a sieve *} +text \Marking out multiples in a sieve\ definition mark_out :: "nat \ marks \ marks" where @@ -78,7 +78,7 @@ nth_enumerate_eq less_eq_dvd_minus) -text {* Auxiliary operation for efficient implementation *} +text \Auxiliary operation for efficient implementation\ definition mark_out_aux :: "nat \ nat \ marks \ marks" where @@ -104,15 +104,15 @@ assume "\ q > 0" with q show False by simp qed - with `n > 0` have "Suc n * q \ 2" by (auto simp add: gr0_conv_Suc) + with \n > 0\ have "Suc n * q \ 2" by (auto simp add: gr0_conv_Suc) with q have a: "a = Suc n * q - 2" by simp with B have "q + n * q < n + n + 2" by auto then have "m * q < m * 2" by (simp add: m_def) - with `m > 0` have "q < 2" by simp - with `q > 0` have "q = 1" by simp + with \m > 0\ have "q < 2" by simp + with \q > 0\ have "q = 1" by simp with a have "a = n - 1" by simp - with `n > 0` C show False by simp + with \n > 0\ C show False by simp qed } note aux = this show ?thesis @@ -157,7 +157,7 @@ qed -text {* Main entry point to sieve *} +text \Main entry point to sieve\ fun sieve :: "nat \ marks \ marks" where @@ -165,7 +165,7 @@ | "sieve n (False # bs) = False # sieve (Suc n) bs" | "sieve n (True # bs) = True # sieve (Suc n) (mark_out n bs)" -text {* +text \ There are the following possible optimisations here: \begin{itemize} @@ -179,7 +179,7 @@ \end{itemize} This is left as an constructive exercise to the reader. -*} +\ lemma numbers_of_marks_sieve: "numbers_of_marks (Suc n) (sieve n bs) = @@ -199,15 +199,15 @@ assume "n > 0 \ n - 1 \ M" then have "n > 0" and "n - 1 \ M" by auto then have "Suc (n - 1) \ Suc ` M" by blast - with `n > 0` show "n \ Suc ` M" by simp + with \n > 0\ show "n \ Suc ` M" by simp qed { fix m :: nat assume "Suc (Suc n) \ m" and "m dvd Suc n" - from `m dvd Suc n` obtain q where "Suc n = m * q" .. - with `Suc (Suc n) \ m` have "Suc (m * q) \ m" by simp + from \m dvd Suc n\ obtain q where "Suc n = m * q" .. + with \Suc (Suc n) \ m\ have "Suc (m * q) \ m" by simp then have "m * q < m" by arith then have "q = 0" by simp - with `Suc n = m * q` have False by simp + with \Suc n = m * q\ have False by simp } note aux1 = this { fix m q :: nat assume "\q>0. 1 < q \ Suc n < q \ q \ Suc (n + length bs) @@ -219,7 +219,7 @@ then have "\ Suc n dvd q" by (auto elim: dvdE) moreover assume "Suc n < q" and "q \ Suc (n + length bs)" and "bs ! (q - Suc (Suc n))" - moreover note `q dvd m` + moreover note \q dvd m\ ultimately have "m dvd q" by (auto intro: *) } note aux2 = this from 3 show ?case @@ -234,7 +234,7 @@ qed -text {* Relation of the sieve algorithm to actual primes *} +text \Relation of the sieve algorithm to actual primes\ definition primes_upto :: "nat \ nat list" where @@ -267,11 +267,11 @@ assume *: "\m\{Suc (Suc 0).. q dvd m" and "m dvd q" and "m \ 1" have "m = q" proof (cases "m = 0") - case True with `m dvd q` show ?thesis by simp + case True with \m dvd q\ show ?thesis by simp next - case False with `m \ 1` have "Suc (Suc 0) \ m" by arith - with `m < Suc n` * `m dvd q` have "q dvd m" by simp - with `m dvd q` show ?thesis by (simp add: dvd.eq_iff) + case False with \m \ 1\ have "Suc (Suc 0) \ m" by arith + with \m < Suc n\ * \m dvd q\ have "q dvd m" by simp + with \m dvd q\ show ?thesis by (simp add: dvd.eq_iff) qed } then have aux: "\m q. Suc (Suc 0) \ q \ @@ -303,7 +303,7 @@ by (simp add: set_primes_upto) -subsection {* Application: smallest prime beyond a certain number *} +subsection \Application: smallest prime beyond a certain number\ definition smallest_prime_beyond :: "nat \ nat" where @@ -348,7 +348,7 @@ def A \ "{p. p \ n \ prime p \ m \ p}" assume assms: "m \ p" "prime p" "p \ n" then have "smallest_prime_beyond m \ p" by (auto intro: smallest_prime_beyond_smallest) - from this `p \ n` have *: "smallest_prime_beyond m \ n" by (rule order_trans) + from this \p \ n\ have *: "smallest_prime_beyond m \ n" by (rule order_trans) from assms have ex: "\p\n. prime p \ m \ p" by auto then have "finite A" by (auto simp add: A_def) with * have "Min A = smallest_prime_beyond m" diff -r 278b65d9339c -r fad653acf58f src/HOL/Number_Theory/Euclidean_Algorithm.thy --- a/src/HOL/Number_Theory/Euclidean_Algorithm.thy Fri Jun 19 21:33:03 2015 +0200 +++ b/src/HOL/Number_Theory/Euclidean_Algorithm.thy Fri Jun 19 21:41:33 2015 +0200 @@ -1,12 +1,12 @@ (* Author: Manuel Eberl *) -section {* Abstract euclidean algorithm *} +section \Abstract euclidean algorithm\ theory Euclidean_Algorithm imports Complex_Main begin -text {* +text \ A Euclidean semiring is a semiring upon which the Euclidean algorithm can be implemented. It must provide: \begin{itemize} @@ -18,7 +18,7 @@ \end{itemize} The existence of these functions makes it possible to derive gcd and lcm functions for any Euclidean semiring. -*} +\ class euclidean_semiring = semiring_div + fixes euclidean_size :: "'a \ nat" fixes normalization_factor :: "'a \ 'a" @@ -60,17 +60,17 @@ proof (cases "a = 0", simp) assume "a \ 0" let ?nf = "normalization_factor" - from normalization_factor_is_unit[OF `a \ 0`] have "?nf a \ 0" + from normalization_factor_is_unit[OF \a \ 0\] have "?nf a \ 0" by auto have "?nf (a div ?nf a) * ?nf (?nf a) = ?nf (a div ?nf a * ?nf a)" by (simp add: normalization_factor_mult) - also have "a div ?nf a * ?nf a = a" using `a \ 0` + also have "a div ?nf a * ?nf a = a" using \a \ 0\ by simp - also have "?nf (?nf a) = ?nf a" using `a \ 0` + also have "?nf (?nf a) = ?nf a" using \a \ 0\ normalization_factor_is_unit normalization_factor_unit by simp finally have "normalization_factor (a div normalization_factor a) = 1" - using `?nf a \ 0` by (metis div_mult_self2_is_id div_self) - with `a \ 0` show ?thesis by simp + using \?nf a \ 0\ by (metis div_mult_self2_is_id div_self) + with \a \ 0\ show ?thesis by simp qed lemma normalization_0_iff [simp]: @@ -90,7 +90,7 @@ apply (subst (asm) unit_eq_div1, blast, subst (asm) unit_div_commute, blast) apply (subst div_mult_swap, simp, simp) done - with `a \ 0` `b \ 0` have "\c. is_unit c \ a = c * b" + with \a \ 0\ \b \ 0\ have "\c. is_unit c \ a = c * b" by (intro exI[of _ "?nf a div ?nf b"], force simp: mult_ac) then obtain c where "is_unit c" and "a = c * b" by blast then show "associated a b" by (rule is_unit_associatedI) @@ -99,7 +99,7 @@ assume "a \ 0" "b \ 0" "associated a b" then obtain c where "is_unit c" and "a = c * b" by (blast elim: associated_is_unitE) then show "a div ?nf a = b div ?nf b" - apply (simp only: `a = c * b` normalization_factor_mult normalization_factor_unit) + apply (simp only: \a = c * b\ normalization_factor_mult normalization_factor_unit) apply (rule div_mult_mult1, force) done qed @@ -129,10 +129,10 @@ assume "b mod a \ 0" from b_dvd_a have b_dvd_mod: "b dvd b mod a" by (simp add: dvd_mod_iff) from b_dvd_mod obtain c where "b mod a = b * c" unfolding dvd_def by blast - with `b mod a \ 0` have "c \ 0" by auto - with `b mod a = b * c` have "euclidean_size (b mod a) \ euclidean_size b" + with \b mod a \ 0\ have "c \ 0" by auto + with \b mod a = b * c\ have "euclidean_size (b mod a) \ euclidean_size b" using size_mult_mono by force - moreover from `a \ 0` have "euclidean_size (b mod a) < euclidean_size a" + moreover from \a \ 0\ have "euclidean_size (b mod a) < euclidean_size a" using mod_size_less by blast ultimately show False using size_eq by simp qed @@ -272,7 +272,7 @@ fix l assume "l dvd a" and "l dvd gcd b c" with dvd_trans[OF _ gcd_dvd1] and dvd_trans[OF _ gcd_dvd2] have "l dvd b" and "l dvd c" by blast+ - with `l dvd a` show "l dvd gcd (gcd a b) c" + with \l dvd a\ show "l dvd gcd (gcd a b) c" by (intro gcd_greatest) qed next @@ -369,7 +369,7 @@ proof - have "gcd a b dvd a" by (rule gcd_dvd1) then obtain c where A: "a = gcd a b * c" unfolding dvd_def by blast - with `a \ 0` show ?thesis by (subst (2) A, intro size_mult_mono) auto + with \a \ 0\ show ?thesis by (subst (2) A, intro size_mult_mono) auto qed lemma euclidean_size_gcd_le2 [simp]: @@ -381,11 +381,11 @@ shows "euclidean_size (gcd a b) < euclidean_size a" proof (rule ccontr) assume "\euclidean_size (gcd a b) < euclidean_size a" - with `a \ 0` have "euclidean_size (gcd a b) = euclidean_size a" + with \a \ 0\ have "euclidean_size (gcd a b) = euclidean_size a" by (intro le_antisym, simp_all) with assms have "a dvd gcd a b" by (auto intro: dvd_euclidean_size_eq_imp_dvd) hence "a dvd b" using dvd_gcd_D2 by blast - with `\a dvd b` show False by contradiction + with \\a dvd b\ show False by contradiction qed lemma euclidean_size_gcd_less2: @@ -445,7 +445,7 @@ let ?nf = "normalization_factor" from assms gcd_mult_distrib [of a c b] have A: "a = gcd (a * c) (a * b) * ?nf a" by simp - from `c dvd a * b` show ?thesis by (subst A, simp_all add: gcd_greatest) + from \c dvd a * b\ show ?thesis by (subst A, simp_all add: gcd_greatest) qed lemma coprime_dvd_mult_iff: @@ -472,7 +472,7 @@ shows "gcd (k * m) n = gcd m n" proof (rule gcd_dvd_antisym) have "gcd (gcd (k * m) n) k = gcd (gcd k n) (k * m)" by (simp add: ac_simps) - also note `gcd k n = 1` + also note \gcd k n = 1\ finally have "gcd (gcd (k * m) n) k = 1" by simp hence "gcd (k * m) n dvd m" by (rule coprime_dvd_mult, simp add: ac_simps) moreover have "gcd (k * m) n dvd n" by simp @@ -488,14 +488,14 @@ assume ?rhs then show ?lhs unfolding associated_def by (fast intro: mult_dvd_mono) next assume ?lhs - from `?lhs` have "a dvd b * d" unfolding associated_def by (metis dvd_mult_left) + from \?lhs\ have "a dvd b * d" unfolding associated_def by (metis dvd_mult_left) hence "a dvd b" by (simp add: coprime_dvd_mult_iff) - moreover from `?lhs` have "b dvd a * c" unfolding associated_def by (metis dvd_mult_left) + moreover from \?lhs\ have "b dvd a * c" unfolding associated_def by (metis dvd_mult_left) hence "b dvd a" by (simp add: coprime_dvd_mult_iff) - moreover from `?lhs` have "c dvd d * b" + moreover from \?lhs\ have "c dvd d * b" unfolding associated_def by (auto dest: dvd_mult_right simp add: ac_simps) hence "c dvd d" by (simp add: coprime_dvd_mult_iff gcd.commute) - moreover from `?lhs` have "d dvd c * a" + moreover from \?lhs\ have "d dvd c * a" unfolding associated_def by (auto dest: dvd_mult_right simp add: ac_simps) hence "d dvd c" by (simp add: coprime_dvd_mult_iff gcd.commute) ultimately show ?rhs unfolding associated_def by simp @@ -536,7 +536,7 @@ moreover from nz have "d \ 0" by simp with div_mult_self1_is_id have "d * (l * u) div d = l * u" . ultimately have "1 = l * u" - using `d \ 0` by simp + using \d \ 0\ by simp then show "l dvd 1" .. qed @@ -555,7 +555,7 @@ proof (rule coprimeI) fix l assume "l dvd d" and "l dvd a" hence "l dvd a * b" by simp - with `l dvd d` and dab show "l dvd 1" by (auto intro: gcd_greatest) + with \l dvd d\ and dab show "l dvd 1" by (auto intro: gcd_greatest) qed lemma coprime_rmult: @@ -564,7 +564,7 @@ proof (rule coprimeI) fix l assume "l dvd d" and "l dvd b" hence "l dvd a * b" by simp - with `l dvd d` and dab show "l dvd 1" by (auto intro: gcd_greatest) + with \l dvd d\ and dab show "l dvd 1" by (auto intro: gcd_greatest) qed lemma coprime_mul_eq: "gcd d (a * b) = 1 \ gcd d a = 1 \ gcd d b = 1" @@ -655,7 +655,7 @@ with dc have "a' dvd b*c" using dvd_trans[of a' a "b*c"] by simp from dc ab'(1,2) have "a'*?d dvd (b'*?d) * c" by simp hence "?d * a' dvd ?d * (b' * c)" by (simp add: mult_ac) - with `?d \ 0` have "a' dvd b' * c" by simp + with \?d \ 0\ have "a' dvd b' * c" by simp with coprime_dvd_mult[OF ab'(3)] have "a' dvd c" by (subst (asm) ac_simps, blast) with ab'(1) have "a = ?d * a' \ ?d dvd b \ a' dvd c" by (simp add: mult_ac) @@ -672,8 +672,8 @@ let ?d = "gcd a b" assume "?d \ 0" from n obtain m where m: "n = Suc m" by (cases n, simp_all) - from `?d \ 0` have zn: "?d ^ n \ 0" by (rule power_not_zero) - from gcd_coprime_exists[OF `?d \ 0`] + from \?d \ 0\ have zn: "?d ^ n \ 0" by (rule power_not_zero) + from gcd_coprime_exists[OF \?d \ 0\] obtain a' b' where ab': "a = a' * ?d" "b = b' * ?d" "gcd a' b' = 1" by blast from ab have "(a' * ?d) ^ n dvd (b' * ?d) ^ n" @@ -755,7 +755,7 @@ hence "gcd a b \ 0" by simp from lcm_gcd have "lcm a b * gcd a b = gcd a b * (a * b div (?nf (a*b) * gcd a b))" by (simp add: mult_ac) - also from `a * b \ 0` have "... = a * b div ?nf (a*b)" + also from \a * b \ 0\ have "... = a * b div ?nf (a*b)" by (simp add: div_mult_swap mult.commute) finally show ?thesis . qed (auto simp add: lcm_gcd) @@ -766,11 +766,11 @@ assume "a * b \ 0" hence "gcd a b \ 0" by simp let ?c = "1 div normalization_factor (a * b)" - from `a * b \ 0` have [simp]: "is_unit (normalization_factor (a * b))" by simp + from \a * b \ 0\ have [simp]: "is_unit (normalization_factor (a * b))" by simp from lcm_gcd_prod[of a b] have "lcm a b * gcd a b = a * ?c * b" by (simp add: div_mult_swap unit_div_commute) hence "lcm a b * gcd a b div gcd a b = a * ?c * b div gcd a b" by simp - with `gcd a b \ 0` have "lcm a b = a * ?c * b div gcd a b" + with \gcd a b \ 0\ have "lcm a b = a * ?c * b div gcd a b" by (subst (asm) div_mult_self2_is_id, simp_all) also have "... = a * (?c * b div gcd a b)" by (metis div_mult_swap gcd_dvd2 mult_assoc) @@ -785,36 +785,36 @@ hence "is_unit (?nf k)" by simp hence "?nf k \ 0" by (metis not_is_unit_0) assume A: "a dvd k" "b dvd k" - hence "gcd a b \ 0" using `k \ 0` by auto + hence "gcd a b \ 0" using \k \ 0\ by auto from A obtain r s where ar: "k = a * r" and bs: "k = b * s" unfolding dvd_def by blast - with `k \ 0` have "r * s \ 0" + with \k \ 0\ have "r * s \ 0" by auto (drule sym [of 0], simp) hence "is_unit (?nf (r * s))" by simp let ?c = "?nf k div ?nf (r*s)" - from `is_unit (?nf k)` and `is_unit (?nf (r * s))` have "is_unit ?c" by (rule unit_div) + from \is_unit (?nf k)\ and \is_unit (?nf (r * s))\ have "is_unit ?c" by (rule unit_div) hence "?c \ 0" using not_is_unit_0 by fast from ar bs have "k * k * gcd s r = ?nf k * k * gcd (k * s) (k * r)" by (subst mult_assoc, subst gcd_mult_distrib[of k s r], simp only: ac_simps) also have "... = ?nf k * k * gcd ((r*s) * a) ((r*s) * b)" - by (subst (3) `k = a * r`, subst (3) `k = b * s`, simp add: algebra_simps) - also have "... = ?c * r*s * k * gcd a b" using `r * s \ 0` + by (subst (3) \k = a * r\, subst (3) \k = b * s\, simp add: algebra_simps) + also have "... = ?c * r*s * k * gcd a b" using \r * s \ 0\ by (subst gcd_mult_distrib'[symmetric], simp add: algebra_simps unit_simps) finally have "(a*r) * (b*s) * gcd s r = ?c * k * r * s * gcd a b" by (subst ar[symmetric], subst bs[symmetric], simp add: mult_ac) hence "a * b * gcd s r * (r * s) = ?c * k * gcd a b * (r * s)" by (simp add: algebra_simps) - hence "?c * k * gcd a b = a * b * gcd s r" using `r * s \ 0` + hence "?c * k * gcd a b = a * b * gcd s r" using \r * s \ 0\ by (metis div_mult_self2_is_id) also have "... = lcm a b * gcd a b * gcd s r * ?nf (a*b)" by (subst lcm_gcd_prod[of a b], metis gcd_mult_distrib gcd_mult_distrib') also have "... = lcm a b * gcd s r * ?nf (a*b) * gcd a b" by (simp add: algebra_simps) - finally have "k * ?c = lcm a b * gcd s r * ?nf (a*b)" using `gcd a b \ 0` + finally have "k * ?c = lcm a b * gcd s r * ?nf (a*b)" using \gcd a b \ 0\ by (metis mult.commute div_mult_self2_is_id) - hence "k = lcm a b * (gcd s r * ?nf (a*b)) div ?c" using `?c \ 0` + hence "k = lcm a b * (gcd s r * ?nf (a*b)) div ?c" using \?c \ 0\ by (metis div_mult_self2_is_id mult_assoc) - also have "... = lcm a b * (gcd s r * ?nf (a*b) div ?c)" using `is_unit ?c` + also have "... = lcm a b * (gcd s r * ?nf (a*b) div ?c)" using \is_unit ?c\ by (simp add: unit_simps) finally show ?thesis by (rule dvdI) qed simp @@ -826,7 +826,7 @@ { assume "a \ 0" "b \ 0" hence "a * b div ?nf (a * b) \ 0" by (simp add: no_zero_divisors) - moreover from `a \ 0` and `b \ 0` have "gcd a b \ 0" by simp + moreover from \a \ 0\ and \b \ 0\ have "gcd a b \ 0" by simp ultimately have "lcm a b \ 0" using lcm_gcd_prod[of a b] by (intro notI, simp) } moreover { assume "a = 0 \ b = 0" @@ -843,12 +843,12 @@ proof- from assms have "gcd a b \ 0" by (simp add: lcm_zero) let ?c = "normalization_factor (a * b)" - from `lcm a b \ 0` have "?c \ 0" by (intro notI, simp add: lcm_zero no_zero_divisors) + from \lcm a b \ 0\ have "?c \ 0" by (intro notI, simp add: lcm_zero no_zero_divisors) hence "is_unit ?c" by simp from lcm_gcd_prod [of a b] have "gcd a b = a * b div ?c div lcm a b" - by (subst (2) div_mult_self2_is_id[OF `lcm a b \ 0`, symmetric], simp add: mult_ac) - also from `is_unit ?c` have "... = a * b div (lcm a b * ?c)" - by (metis `?c \ 0` div_mult_mult1 dvd_mult_div_cancel mult_commute normalization_factor_dvd') + by (subst (2) div_mult_self2_is_id[OF \lcm a b \ 0\, symmetric], simp add: mult_ac) + also from \is_unit ?c\ have "... = a * b div (lcm a b * ?c)" + by (metis \?c \ 0\ div_mult_mult1 dvd_mult_div_cancel mult_commute normalization_factor_dvd') finally show ?thesis . qed @@ -891,11 +891,11 @@ fix l assume "a dvd l" and "lcm b c dvd l" have "b dvd lcm b c" by simp - from this and `lcm b c dvd l` have "b dvd l" by (rule dvd_trans) + from this and \lcm b c dvd l\ have "b dvd l" by (rule dvd_trans) have "c dvd lcm b c" by simp - from this and `lcm b c dvd l` have "c dvd l" by (rule dvd_trans) - from `a dvd l` and `b dvd l` have "lcm a b dvd l" by (rule lcm_least) - from this and `c dvd l` show "lcm (lcm a b) c dvd l" by (rule lcm_least) + from this and \lcm b c dvd l\ have "c dvd l" by (rule dvd_trans) + from \a dvd l\ and \b dvd l\ have "lcm a b dvd l" by (rule lcm_least) + from this and \c dvd l\ show "lcm (lcm a b) c dvd l" by (rule lcm_least) qed (simp add: lcm_zero) next fix a b @@ -926,7 +926,7 @@ hence "is_unit (lcm a b)" by (rule lcm_least) hence "lcm a b = normalization_factor (lcm a b)" by (subst normalization_factor_unit, simp_all) - also have "\ = 1" using `is_unit a \ is_unit b` + also have "\ = 1" using \is_unit a \ is_unit b\ by auto finally show "lcm a b = 1" . qed @@ -999,7 +999,7 @@ proof - have "a dvd lcm a b" by (rule lcm_dvd1) then obtain c where A: "lcm a b = a * c" unfolding dvd_def by blast - with `a \ 0` and `b \ 0` have "c \ 0" by (auto simp: lcm_zero) + with \a \ 0\ and \b \ 0\ have "c \ 0" by (auto simp: lcm_zero) then show ?thesis by (subst A, intro size_mult_mono) qed @@ -1013,12 +1013,12 @@ proof (rule ccontr) from assms have "a \ 0" by auto assume "\euclidean_size a < euclidean_size (lcm a b)" - with `a \ 0` and `b \ 0` have "euclidean_size (lcm a b) = euclidean_size a" + with \a \ 0\ and \b \ 0\ have "euclidean_size (lcm a b) = euclidean_size a" by (intro le_antisym, simp, intro euclidean_size_lcm_le1) with assms have "lcm a b dvd a" by (rule_tac dvd_euclidean_size_eq_imp_dvd) (auto simp: lcm_zero) hence "b dvd a" by (rule dvd_lcm_D2) - with `\b dvd a` show False by contradiction + with \\b dvd a\ show False by contradiction qed lemma euclidean_size_lcm_less2: @@ -1101,8 +1101,8 @@ unfolding l_def by simp_all { fix l' assume "\a\A. a dvd l'" - with `\a\A. a dvd l` have "\a\A. a dvd gcd l l'" by (auto intro: gcd_greatest) - moreover from `l \ 0` have "gcd l l' \ 0" by simp + with \\a\A. a dvd l\ have "\a\A. a dvd gcd l l'" by (auto intro: gcd_greatest) + moreover from \l \ 0\ have "gcd l l' \ 0" by simp ultimately have "\b. b \ 0 \ (\a\A. a dvd b) \ euclidean_size b = euclidean_size (gcd l l')" by (intro exI[of _ "gcd l l'"], auto) hence "euclidean_size (gcd l l') \ n" by (subst n_def) (rule Least_le) @@ -1110,20 +1110,20 @@ proof - have "gcd l l' dvd l" by simp then obtain a where "l = gcd l l' * a" unfolding dvd_def by blast - with `l \ 0` have "a \ 0" by auto + with \l \ 0\ have "a \ 0" by auto hence "euclidean_size (gcd l l') \ euclidean_size (gcd l l' * a)" by (rule size_mult_mono) - also have "gcd l l' * a = l" using `l = gcd l l' * a` .. - also note `euclidean_size l = n` + also have "gcd l l' * a = l" using \l = gcd l l' * a\ .. + also note \euclidean_size l = n\ finally show "euclidean_size (gcd l l') \ n" . qed ultimately have "euclidean_size l = euclidean_size (gcd l l')" - by (intro le_antisym, simp_all add: `euclidean_size l = n`) - with `l \ 0` have "l dvd gcd l l'" by (blast intro: dvd_euclidean_size_eq_imp_dvd) + by (intro le_antisym, simp_all add: \euclidean_size l = n\) + with \l \ 0\ have "l dvd gcd l l'" by (blast intro: dvd_euclidean_size_eq_imp_dvd) hence "l dvd l'" by (blast dest: dvd_gcd_D2) } - with `(\a\A. a dvd l)` and normalization_factor_is_unit[OF `l \ 0`] and `l \ 0` + with \(\a\A. a dvd l)\ and normalization_factor_is_unit[OF \l \ 0\] and \l \ 0\ have "(\a\A. a dvd l div normalization_factor l) \ (\l'. (\a\A. a dvd l') \ l div normalization_factor l dvd l') \ normalization_factor (l div normalization_factor l) = @@ -1206,7 +1206,7 @@ hence "l div normalization_factor l \ 0" by simp also from ex have "l div normalization_factor l = Lcm A" by (simp only: Lcm_Lcm_eucl Lcm_eucl_def n_def l_def if_True Let_def) - finally show False using `Lcm A = 0` by contradiction + finally show False using \Lcm A = 0\ by contradiction qed qed (simp only: Lcm_Lcm_eucl Lcm_eucl_def if_False) @@ -1218,13 +1218,13 @@ moreover { assume "0 \ A" hence "\A \ 0" - apply (induct rule: finite_induct[OF `finite A`]) + apply (induct rule: finite_induct[OF \finite A\]) apply simp apply (subst setprod.insert, assumption, assumption) apply (rule no_zero_divisors) apply blast+ done - moreover from `finite A` have "\a\A. a dvd \A" by blast + moreover from \finite A\ have "\a\A. a dvd \A" by blast ultimately have "\l. l \ 0 \ (\a\A. a dvd l)" by blast with Lcm0_iff' have "Lcm A \ 0" by simp } @@ -1244,13 +1244,13 @@ proof (rule lcmI) fix l assume "a dvd l" and "Lcm A dvd l" hence "\a\A. a dvd l" by (blast intro: dvd_trans dvd_Lcm) - with `a dvd l` show "Lcm (insert a A) dvd l" by (force intro: Lcm_dvd) + with \a dvd l\ show "Lcm (insert a A) dvd l" by (force intro: Lcm_dvd) qed (auto intro: Lcm_dvd dvd_Lcm) lemma Lcm_finite: assumes "finite A" shows "Lcm A = Finite_Set.fold lcm 1 A" - by (induct rule: finite.induct[OF `finite A`]) + by (induct rule: finite.induct[OF \finite A\]) (simp_all add: comp_fun_idem.fold_insert_idem[OF comp_fun_idem_lcm]) lemma Lcm_set [code_unfold]: @@ -1337,13 +1337,13 @@ proof (rule gcdI) fix l assume "l dvd a" and "l dvd Gcd A" hence "\a\A. l dvd a" by (blast intro: dvd_trans Gcd_dvd) - with `l dvd a` show "l dvd Gcd (insert a A)" by (force intro: Gcd_dvd) + with \l dvd a\ show "l dvd Gcd (insert a A)" by (force intro: Gcd_dvd) qed auto lemma Gcd_finite: assumes "finite A" shows "Gcd A = Finite_Set.fold gcd 0 A" - by (induct rule: finite.induct[OF `finite A`]) + by (induct rule: finite.induct[OF \finite A\]) (simp_all add: comp_fun_idem.fold_insert_idem[OF comp_fun_idem_gcd]) lemma Gcd_set [code_unfold]: @@ -1361,10 +1361,10 @@ end -text {* +text \ A Euclidean ring is a Euclidean semiring with additive inverses. It provides a few more lemmas; in particular, Bezout's lemma holds for any Euclidean ring. -*} +\ class euclidean_ring = euclidean_semiring + idom diff -r 278b65d9339c -r fad653acf58f src/HOL/Number_Theory/Fib.thy --- a/src/HOL/Number_Theory/Fib.thy Fri Jun 19 21:33:03 2015 +0200 +++ b/src/HOL/Number_Theory/Fib.thy Fri Jun 19 21:41:33 2015 +0200 @@ -8,14 +8,14 @@ Jeremy Avigad. *) -section {* Fib *} +section \Fib\ theory Fib imports Main "../GCD" "../Binomial" begin -subsection {* Fibonacci numbers *} +subsection \Fibonacci numbers\ fun fib :: "nat \ nat" where @@ -23,7 +23,7 @@ | fib1: "fib (Suc 0) = 1" | fib2: "fib (Suc (Suc n)) = fib (Suc n) + fib n" -subsection {* Basic Properties *} +subsection \Basic Properties\ lemma fib_1 [simp]: "fib (1::nat) = 1" by (metis One_nat_def fib1) @@ -41,12 +41,12 @@ lemma fib_neq_0_nat: "n > 0 \ fib n > 0" by (induct n rule: fib.induct) (auto simp add: ) -subsection {* A Few Elementary Results *} +subsection \A Few Elementary Results\ -text {* +text \ \medskip Concrete Mathematics, page 278: Cassini's identity. The proof is much easier using integers, not natural numbers! -*} +\ lemma fib_Cassini_int: "int (fib (Suc (Suc n)) * fib n) - int((fib (Suc n))\<^sup>2) = - ((-1)^n)" by (induction n rule: fib.induct) (auto simp add: field_simps power2_eq_square power_add) @@ -57,7 +57,7 @@ using fib_Cassini_int [of n] by auto -subsection {* Law 6.111 of Concrete Mathematics *} +subsection \Law 6.111 of Concrete Mathematics\ lemma coprime_fib_Suc_nat: "coprime (fib (n::nat)) (fib (Suc n))" apply (induct n rule: fib.induct) @@ -86,13 +86,13 @@ case True then have "m \ n" by auto with pos_m have pos_n: "0 < n" by auto - with pos_m `m < n` have diff: "n - m < n" by auto + with pos_m \m < n\ have diff: "n - m < n" by auto have "gcd (fib m) (fib (n mod m)) = gcd (fib m) (fib ((n - m) mod m))" - by (simp add: mod_if [of n]) (insert `m < n`, auto) + by (simp add: mod_if [of n]) (insert \m < n\, auto) also have "\ = gcd (fib m) (fib (n - m))" by (simp add: less.hyps diff pos_m) also have "\ = gcd (fib m) (fib n)" - by (simp add: gcd_fib_diff `m \ n`) + by (simp add: gcd_fib_diff \m \ n\) finally show "gcd (fib m) (fib (n mod m)) = gcd (fib m) (fib n)" . next case False @@ -102,14 +102,14 @@ qed lemma fib_gcd: "fib (gcd m n) = gcd (fib m) (fib n)" - -- {* Law 6.111 *} + -- \Law 6.111\ by (induct m n rule: gcd_nat_induct) (simp_all add: gcd_non_0_nat gcd_commute_nat gcd_fib_mod) theorem fib_mult_eq_setsum_nat: "fib (Suc n) * fib n = (\k \ {..n}. fib k * fib k)" by (induct n rule: nat.induct) (auto simp add: field_simps) -subsection {* Fibonacci and Binomial Coefficients *} +subsection \Fibonacci and Binomial Coefficients\ lemma setsum_drop_zero: "(\k = 0..Suc n. if 0j = 0..n. f j)" by (induct n) auto diff -r 278b65d9339c -r fad653acf58f src/HOL/Number_Theory/Gauss.thy --- a/src/HOL/Number_Theory/Gauss.thy Fri Jun 19 21:33:03 2015 +0200 +++ b/src/HOL/Number_Theory/Gauss.thy Fri Jun 19 21:41:33 2015 +0200 @@ -3,7 +3,7 @@ Ported by lcp but unfinished *) -section {* Gauss' Lemma *} +section \Gauss' Lemma\ theory Gauss imports Residues @@ -38,7 +38,7 @@ definition "F = (\x. (int p - x)) ` E" -subsection {* Basic properties of p *} +subsection \Basic properties of p\ lemma odd_p: "odd p" by (metis p_prime p_ge_2 prime_odd_nat) @@ -60,7 +60,7 @@ by (auto simp add: even_iff_mod_2_eq_zero) (metis p_eq2) -subsection {* Basic Properties of the Gauss Sets *} +subsection \Basic Properties of the Gauss Sets\ lemma finite_A: "finite (A)" by (auto simp add: A_def) @@ -208,7 +208,7 @@ by (metis id_def all_A_relprime setprod_coprime_int) -subsection {* Relationships Between Gauss Sets *} +subsection \Relationships Between Gauss Sets\ lemma StandardRes_inj_on_ResSet: "ResSet m X \ (inj_on (\b. b mod m) X)" by (auto simp add: ResSet_def inj_on_def cong_int_def) @@ -315,7 +315,7 @@ qed -subsection {* Gauss' Lemma *} +subsection \Gauss' Lemma\ lemma aux: "setprod id A * (- 1) ^ card E * a ^ card A * (- 1) ^ card E = setprod id A * a ^ card A" by (metis (no_types) minus_minus mult.commute mult.left_commute power_minus power_one) diff -r 278b65d9339c -r fad653acf58f src/HOL/Number_Theory/MiscAlgebra.thy --- a/src/HOL/Number_Theory/MiscAlgebra.thy Fri Jun 19 21:33:03 2015 +0200 +++ b/src/HOL/Number_Theory/MiscAlgebra.thy Fri Jun 19 21:41:33 2015 +0200 @@ -291,7 +291,7 @@ proof - have "(x \ \) \ (x \ \ \) = x \ x \ \ \" by (simp add: ring_simprules) - also from `x \ x = \` have "\ = \" + also from \x \ x = \\ have "\ = \" by (simp add: ring_simprules) finally have "(x \ \) \ (x \ \ \) = \" . then have "(x \ \) = \ | (x \ \ \) = \" diff -r 278b65d9339c -r fad653acf58f src/HOL/Number_Theory/Number_Theory.thy --- a/src/HOL/Number_Theory/Number_Theory.thy Fri Jun 19 21:33:03 2015 +0200 +++ b/src/HOL/Number_Theory/Number_Theory.thy Fri Jun 19 21:41:33 2015 +0200 @@ -1,5 +1,5 @@ -section {* Comprehensive number theory *} +section \Comprehensive number theory\ theory Number_Theory imports Fib Residues Eratosthenes diff -r 278b65d9339c -r fad653acf58f src/HOL/Number_Theory/Pocklington.thy --- a/src/HOL/Number_Theory/Pocklington.thy Fri Jun 19 21:33:03 2015 +0200 +++ b/src/HOL/Number_Theory/Pocklington.thy Fri Jun 19 21:41:33 2015 +0200 @@ -2,13 +2,13 @@ Author: Amine Chaieb *) -section {* Pocklington's Theorem for Primes *} +section \Pocklington's Theorem for Primes\ theory Pocklington imports Residues begin -subsection{*Lemmas about previously defined terms*} +subsection\Lemmas about previously defined terms\ lemma prime: "prime p \ p \ 0 \ p\1 \ (\m. 0 < m \ m < p \ coprime p m)" @@ -52,7 +52,7 @@ qed -subsection{*Some basic theorems about solving congruences*} +subsection\Some basic theorems about solving congruences\ lemma cong_solve: fixes n::nat assumes an: "coprime a n" shows "\x. [a * x = b] (mod n)" @@ -135,7 +135,7 @@ qed -subsection{*Lucas's theorem*} +subsection\Lucas's theorem\ lemma phi_limit_strong: "phi(n) \ n - 1" proof - @@ -291,7 +291,7 @@ qed -subsection{*Definition of the order of a number mod n (0 in non-coprime case)*} +subsection\Definition of the order of a number mod n (0 in non-coprime case)\ definition "ord n a = (if coprime n a then Least (\d. d > 0 \ [a ^d = 1] (mod n)) else 0)" @@ -442,7 +442,7 @@ ultimately show ?thesis by blast qed -subsection{*Another trivial primality characterization*} +subsection\Another trivial primality characterization\ lemma prime_prime_factor: "prime n \ n \ 1 \ (\p. prime p \ p dvd n \ p = n)" @@ -530,7 +530,7 @@ qed -subsection{*Pocklington theorem*} +subsection\Pocklington theorem\ lemma pocklington_lemma: assumes n: "n \ 2" and nqr: "n - 1 = q*r" and an: "[a^ (n - 1) = 1] (mod n)" @@ -666,7 +666,7 @@ qed -subsection{*Prime factorizations*} +subsection\Prime factorizations\ (* FIXME some overlap with material in UniqueFactorization, class unique_factorization *) diff -r 278b65d9339c -r fad653acf58f src/HOL/Number_Theory/Primes.thy --- a/src/HOL/Number_Theory/Primes.thy Fri Jun 19 21:33:03 2015 +0200 +++ b/src/HOL/Number_Theory/Primes.thy Fri Jun 19 21:41:33 2015 +0200 @@ -25,7 +25,7 @@ *) -section {* Primes *} +section \Primes\ theory Primes imports "~~/src/HOL/GCD" "~~/src/HOL/Binomial" @@ -40,7 +40,7 @@ lemmas prime_nat_def = prime_def -subsection {* Primes *} +subsection \Primes\ lemma prime_odd_nat: "prime p \ p > 2 \ odd p" apply (auto simp add: prime_nat_def even_iff_mod_2_eq_zero dvd_eq_mod_eq_0) @@ -126,7 +126,7 @@ by (cases n) (auto elim: prime_dvd_power_int) -subsubsection {* Make prime naively executable *} +subsubsection \Make prime naively executable\ lemma zero_not_prime_nat [simp]: "~prime (0::nat)" by (simp add: prime_nat_def) @@ -152,7 +152,7 @@ lemma two_is_prime_nat [simp]: "prime (2::nat)" by simp -text{* A bit of regression testing: *} +text\A bit of regression testing:\ lemma "prime(97::nat)" by simp lemma "prime(997::nat)" by eval @@ -181,7 +181,7 @@ nat_dvd_not_less neq0_conv prime_nat_def) done -text {* One property of coprimality is easier to prove via prime factors. *} +text \One property of coprimality is easier to prove via prime factors.\ lemma prime_divprod_pow_nat: assumes p: "prime p" and ab: "coprime a b" and pab: "p^n dvd a * b" @@ -222,7 +222,7 @@ qed -subsection {* Infinitely many primes *} +subsection \Infinitely many primes\ lemma next_prime_bound: "\p. prime p \ n < p \ p <= fact n + 1" proof- @@ -231,18 +231,18 @@ obtain p where "prime p" and "p dvd fact n + 1" by auto then have "p \ fact n + 1" apply (intro dvd_imp_le) apply auto done { assume "p \ n" - from `prime p` have "p \ 1" + from \prime p\ have "p \ 1" by (cases p, simp_all) - with `p <= n` have "p dvd fact n" + with \p <= n\ have "p dvd fact n" by (intro dvd_fact) - with `p dvd fact n + 1` have "p dvd fact n + 1 - fact n" + with \p dvd fact n + 1\ have "p dvd fact n + 1 - fact n" by (rule dvd_diff_nat) then have "p dvd 1" by simp then have "p <= 1" by auto - moreover from `prime p` have "p > 1" by auto + moreover from \prime p\ have "p > 1" by auto ultimately have False by auto} then have "n < p" by presburger - with `prime p` and `p <= fact n + 1` show ?thesis by auto + with \prime p\ and \p <= fact n + 1\ show ?thesis by auto qed lemma bigger_prime: "\p. prime p \ p > (n::nat)" @@ -259,9 +259,9 @@ by auto qed -subsection{*Powers of Primes*} +subsection\Powers of Primes\ -text{*Versions for type nat only*} +text\Versions for type nat only\ lemma prime_product: fixes p::nat @@ -271,7 +271,7 @@ from assms have "1 < p * q" and P: "\m. m dvd p * q \ m = 1 \ m = p * q" unfolding prime_nat_def by auto - from `1 < p * q` have "p \ 0" by (cases p) auto + from \1 < p * q\ have "p \ 0" by (cases p) auto then have Q: "p = p * q \ q = 1" by auto have "p dvd p * q" by simp then have "p = 1 \ p = p * q" by (rule P) @@ -370,7 +370,7 @@ thus "\i\k. d = p ^ i \ d dvd p ^ k" by blast qed -subsection {*Chinese Remainder Theorem Variants*} +subsection \Chinese Remainder Theorem Variants\ lemma bezout_gcd_nat: fixes a::nat shows "\x y. a * x - b * y = gcd a b \ b * x - a * y = gcd a b" @@ -391,7 +391,7 @@ qed -text {* A binary form of the Chinese Remainder Theorem. *} +text \A binary form of the Chinese Remainder Theorem.\ lemma chinese_remainder: fixes a::nat assumes ab: "coprime a b" and a: "a \ 0" and b: "b \ 0" @@ -411,7 +411,7 @@ thus ?thesis by blast qed -text {* Primality *} +text \Primality\ lemma coprime_bezout_strong: fixes a::nat assumes "coprime a b" "b \ 1" diff -r 278b65d9339c -r fad653acf58f src/HOL/Number_Theory/Residues.thy --- a/src/HOL/Number_Theory/Residues.thy Fri Jun 19 21:33:03 2015 +0200 +++ b/src/HOL/Number_Theory/Residues.thy Fri Jun 19 21:41:33 2015 +0200 @@ -5,7 +5,7 @@ Euler's theorem and Wilson's theorem. *) -section {* Residue rings *} +section \Residue rings\ theory Residues imports UniqueFactorization MiscAlgebra @@ -248,7 +248,7 @@ *) -subsection{* Euler's theorem *} +subsection\Euler's theorem\ (* the definition of the phi function *) @@ -276,9 +276,9 @@ apply (rule cop) using * apply auto done - with `x dvd p` `1 < x` have "False" by auto } + with \x dvd p\ \1 < x\ have "False" by auto } then show ?thesis - using `2 \ p` + using \2 \ p\ by (simp add: prime_def) (metis One_nat_def dvd_pos_nat nat_dvd_not_less nat_neq_iff not_gr0 not_numeral_le_zero one_dvd) @@ -374,7 +374,7 @@ by (metis int_1 of_nat_power transfer_int_nat_cong zdvd_int) -subsection {* Wilson's theorem *} +subsection \Wilson's theorem\ lemma (in field) inv_pair_lemma: "x : Units R \ y : Units R \ {x, inv x} ~= {y, inv y} \ {x, inv x} Int {y, inv y} = {}" diff -r 278b65d9339c -r fad653acf58f src/HOL/Number_Theory/UniqueFactorization.thy --- a/src/HOL/Number_Theory/UniqueFactorization.thy Fri Jun 19 21:33:03 2015 +0200 +++ b/src/HOL/Number_Theory/UniqueFactorization.thy Fri Jun 19 21:41:33 2015 +0200 @@ -8,7 +8,7 @@ that, by Jeremy Avigad and David Gray. *) -section {* UniqueFactorization *} +section \UniqueFactorization\ theory UniqueFactorization imports Cong "~~/src/HOL/Library/Multiset" @@ -34,7 +34,7 @@ *) -subsection {* unique factorization: multiset version *} +subsection \unique factorization: multiset version\ lemma multiset_prime_factorization_exists [rule_format]: "n > 0 --> (EX M. (ALL (p::nat) : set_mset M. prime p) & n = (PROD i :# M. i))" @@ -154,7 +154,7 @@ done -subsection {* Prime factors and multiplicity for nats and ints *} +subsection \Prime factors and multiplicity for nats and ints\ class unique_factorization = fixes multiplicity :: "'a \ 'a \ nat" @@ -191,7 +191,7 @@ end -subsection {* Set up transfer *} +subsection \Set up transfer\ lemma transfer_nat_int_prime_factors: "prime_factors (nat n) = nat ` prime_factors n" unfolding prime_factors_int_def @@ -228,7 +228,7 @@ transfer_int_nat_multiplicity] -subsection {* Properties of prime factors and multiplicity for nats and ints *} +subsection \Properties of prime factors and multiplicity for nats and ints\ lemma prime_factors_ge_0_int [elim]: "p : prime_factors (n::int) \ p >= 0" unfolding prime_factors_int_def by auto @@ -308,7 +308,7 @@ using assms apply (simp add: set_mset_def msetprod_multiplicity) done - with `f \ multiset` have "count (multiset_prime_factorization n) = f" + with \f \ multiset\ have "count (multiset_prime_factorization n) = f" by simp with S_eq show ?thesis by (simp add: set_mset_def multiset_def prime_factors_nat_def multiplicity_nat_def) @@ -710,7 +710,7 @@ done -subsection {* An application *} +subsection \An application\ lemma gcd_eq_nat: assumes pos [arith]: "x > 0" "y > 0"