# HG changeset patch # User eberlm # Date 1464108411 -7200 # Node ID feea9cf343d99a035b5c773a5691e715ca0e8676 # Parent 8230358fab884f8cb3700fa580246bc161a1b559 Backed out changeset 8230358fab88 diff -r 8230358fab88 -r feea9cf343d9 src/HOL/Codegenerator_Test/Generate_Efficient_Datastructures.thy --- a/src/HOL/Codegenerator_Test/Generate_Efficient_Datastructures.thy Tue May 24 17:42:14 2016 +0200 +++ b/src/HOL/Codegenerator_Test/Generate_Efficient_Datastructures.thy Tue May 24 18:46:51 2016 +0200 @@ -73,9 +73,6 @@ lemma [code, code del]: "Lcm_eucl = Lcm_eucl" .. -lemma [code, code del]: - "permutations_of_set = permutations_of_set" .. - (* If the code generation ends with an exception with the following message: '"List.set" is not a constructor, on left hand side of equation: ...', diff -r 8230358fab88 -r feea9cf343d9 src/HOL/Number_Theory/Factorial_Ring.thy --- a/src/HOL/Number_Theory/Factorial_Ring.thy Tue May 24 17:42:14 2016 +0200 +++ b/src/HOL/Number_Theory/Factorial_Ring.thy Tue May 24 18:46:51 2016 +0200 @@ -24,104 +24,16 @@ end -context comm_semiring_1 -begin - -definition irreducible :: "'a \ bool" where - "irreducible p \ p \ 0 \ \p dvd 1 \ (\a b. p = a * b \ a dvd 1 \ b dvd 1)" - -lemma not_irreducible_zero [simp]: "\irreducible 0" - by (simp add: irreducible_def) - -lemma irreducible_not_unit: "irreducible p \ \p dvd 1" - by (simp add: irreducible_def) - -lemma irreducibleI: - "p \ 0 \ \p dvd 1 \ (\a b. p = a * b \ a dvd 1 \ b dvd 1) \ irreducible p" - by (simp add: irreducible_def) - -lemma irreducibleD: "irreducible p \ p = a * b \ a dvd 1 \ b dvd 1" - by (simp add: irreducible_def) - -definition is_prime :: "'a \ bool" where - "is_prime p \ p \ 0 \ \p dvd 1 \ (\a b. p dvd (a * b) \ p dvd a \ p dvd b)" - -lemma not_is_prime_zero [simp]: "\is_prime 0" - by (simp add: is_prime_def) - -lemma is_prime_not_unit: "is_prime p \ \p dvd 1" - by (simp add: is_prime_def) - -lemma is_primeI: - "p \ 0 \ \p dvd 1 \ (\a b. p dvd (a * b) \ p dvd a \ p dvd b) \ is_prime p" - by (simp add: is_prime_def) - -lemma prime_divides_productD: - "is_prime p \ p dvd (a * b) \ p dvd a \ p dvd b" - by (simp add: is_prime_def) - -lemma prime_divides_product_iff: - "is_prime p \ p dvd (a * b) \ p dvd a \ p dvd b" - by (auto simp: is_prime_def) - -end - - -context algebraic_semidom -begin - -lemma prime_imp_irreducible: - assumes "prime p" - shows "irreducible p" -proof - - -lemma is_prime_mono: - assumes "is_prime p" "\q dvd 1" "q dvd p" - shows "is_prime q" -proof - - from \q dvd p\ obtain r where r: "p = q * r" by (elim dvdE) - hence "p dvd q * r" by simp - with \is_prime p\ have "p dvd q \ p dvd r" by (rule prime_divides_productD) - hence "p dvd q" - proof - assume "p dvd r" - then obtain s where s: "r = p * s" by (elim dvdE) - from r have "p * 1 = p * (q * s)" by (subst (asm) s) (simp add: mult_ac) - with \is_prime p\ have "q dvd 1" - by (subst (asm) mult_cancel_left) auto - with \\q dvd 1\ show ?thesis by contradiction - qed - - show ?thesis - proof (rule is_primeI) - fix a b assume "q dvd (a * b)" - with \p dvd q\ have "p dvd (a * b)" by (rule dvd_trans) - with \is_prime p\ have "p dvd a \ p dvd b" by (rule prime_divides_productD) - with \q dvd p\ show "q dvd a \ q dvd b" by (blast intro: dvd_trans) - qed (insert assms, auto) -qed - -end - - class factorial_semiring = normalization_semidom + assumes finite_divisors: "a \ 0 \ finite {b. b dvd a \ normalize b = b}" - assumes irreducible_is_prime: "(\b. b dvd a \ - assumes no_prime_divisorsI2: "(\b. b dvd a \ \ is_prime b) \ is_unit a" + fixes is_prime :: "'a \ bool" + assumes not_is_prime_zero [simp]: "\ is_prime 0" + and is_prime_not_unit: "is_prime p \ \ is_unit p" + and no_prime_divisorsI2: "(\b. b dvd a \ \ is_prime b) \ is_unit a" + assumes is_primeI: "p \ 0 \ \ is_unit p \ (\a. a dvd p \ \ is_unit a \ p dvd a) \ is_prime p" + and is_primeD: "is_prime p \ p dvd a * b \ p dvd a \ p dvd b" begin -lemma is_primeI': - assumes "p \ 0" "\ is_unit p" "\a. a dvd p \ \ is_unit a \ p dvd a" - shows "is_prime p" -proof (rule ccontr) - assume "\is_prime p" - with assms obtain a b where "p dvd (a * b)" "\p dvd a" "\p dvd b" - by (auto simp: is_prime_def) - - -qed fact+ - - lemma not_is_prime_one [simp]: "\ is_prime 1" by (auto dest: is_prime_not_unit) diff -r 8230358fab88 -r feea9cf343d9 src/HOL/Probability/Random_Permutations.thy --- a/src/HOL/Probability/Random_Permutations.thy Tue May 24 17:42:14 2016 +0200 +++ b/src/HOL/Probability/Random_Permutations.thy Tue May 24 18:46:51 2016 +0200 @@ -40,7 +40,7 @@ text \ A generic fold function that takes a function, an initial state, and a set and chooses a random order in which it then traverses the set in the same - fashion as a left fold over a list. + fashion as a left-fold over a list. We first give a recursive definition. \ function fold_random_permutation :: "('a \ 'b \ 'b) \ 'b \ 'a set \ 'b pmf" where