- coprime a (p^m)"
+subsubsection{* Make prime naively executable *}
+
+lemma zero_not_prime_nat [simp]: "~prime (0::nat)"
+ by (simp add: prime_nat_def)
+
+lemma zero_not_prime_int [simp]: "~prime (0::int)"
+ by (simp add: prime_int_def)
+
+lemma one_not_prime_nat [simp]: "~prime (1::nat)"
+ by (simp add: prime_nat_def)
+
+lemma Suc_0_not_prime_nat [simp]: "~prime (Suc 0)"
+ by (simp add: prime_nat_def One_nat_def)
+
+lemma one_not_prime_int [simp]: "~prime (1::int)"
+ by (simp add: prime_int_def)
+
+lemma prime_nat_code[code]:
+ "prime(p::nat) = (p > 1 & (ALL n : {1<.. 1 & (list_all (%n. ~ n dvd p) [2..
1 & (ALL n : {1<..
1 & (list_all (%n. ~ n dvd p) [2..p - 1]))"
+apply(simp only:prime_int_code list_ball_code greaterThanLessThan_upto)
+apply simp
+done
+
+lemmas prime_int_simp_number_of[simp] = prime_int_simp[of "number_of m", standard]
+
+declare successor_int_def[simp]
+
+lemma two_is_prime_nat [simp]: "prime (2::nat)"
+by simp
+
+lemma two_is_prime_int [simp]: "prime (2::int)"
+by simp
+
+
+lemma prime_imp_power_coprime_nat: "prime (p::nat) \ ~ p dvd a \ coprime a (p^m)"
apply (rule coprime_exp_nat)
apply (subst gcd_commute_nat)
apply (erule (1) prime_imp_coprime_nat)
done
-lemma prime_imp_power_coprime_int: "prime (p::int) \ ~ p dvd a \
- coprime a (p^m)"
+lemma prime_imp_power_coprime_int: "prime (p::int) \ ~ p dvd a \ coprime a (p^m)"
apply (rule coprime_exp_int)
apply (subst gcd_commute_int)
apply (erule (1) prime_imp_coprime_int)
@@ -1655,12 +1683,10 @@
apply auto
done
-lemma primes_imp_powers_coprime_nat: "prime (p::nat) \ prime q \ p ~= q \
- coprime (p^m) (q^n)"
+lemma primes_imp_powers_coprime_nat: "prime (p::nat) \ prime q \ p ~= q \ coprime (p^m) (q^n)"
by (rule coprime_exp2_nat, rule primes_coprime_nat)
-lemma primes_imp_powers_coprime_int: "prime (p::int) \ prime q \ p ~= q \
- coprime (p^m) (q^n)"
+lemma primes_imp_powers_coprime_int: "prime (p::int) \ prime q \ p ~= q \ coprime (p^m) (q^n)"
by (rule coprime_exp2_int, rule primes_coprime_int)
lemma prime_factor_nat: "n \ (1::nat) \ \ p. prime p \ p dvd n"
diff -r 64a12f353c57 -r efc5f4806cd5 src/HOL/IntDiv.thy
--- a/src/HOL/IntDiv.thy Wed Jul 15 15:09:56 2009 +0200
+++ b/src/HOL/IntDiv.thy Fri Jul 17 10:07:15 2009 +0200
@@ -266,7 +266,7 @@
in
-val cancel_div_mod_int_proc = Simplifier.simproc (the_context ())
+val cancel_div_mod_int_proc = Simplifier.simproc @{theory}
"cancel_zdiv_zmod" ["(k::int) + l"] (K CancelDivMod.proc);
val _ = Addsimprocs [cancel_div_mod_int_proc];
diff -r 64a12f353c57 -r efc5f4806cd5 src/HOL/Lambda/WeakNorm.thy
--- a/src/HOL/Lambda/WeakNorm.thy Wed Jul 15 15:09:56 2009 +0200
+++ b/src/HOL/Lambda/WeakNorm.thy Fri Jul 17 10:07:15 2009 +0200
@@ -1,5 +1,4 @@
(* Title: HOL/Lambda/WeakNorm.thy
- ID: $Id$
Author: Stefan Berghofer
Copyright 2003 TU Muenchen
*)
@@ -430,11 +429,11 @@
val ct1 = @{cterm "%f. ((%f x. f (f (f x))) ((%f x. f (f (f (f x)))) f))"};
val (dB1, _) = @{code type_NF} (typing_of_term [] dummyf (term_of ct1));
-val ct1' = cterm_of (the_context ()) (term_of_dB [] (#T (rep_cterm ct1)) dB1);
+val ct1' = cterm_of @{theory} (term_of_dB [] (#T (rep_cterm ct1)) dB1);
val ct2 = @{cterm "%f x. (%x. f x x) ((%x. f x x) ((%x. f x x) ((%x. f x x) ((%x. f x x) ((%x. f x x) x)))))"};
val (dB2, _) = @{code type_NF} (typing_of_term [] dummyf (term_of ct2));
-val ct2' = cterm_of (the_context ()) (term_of_dB [] (#T (rep_cterm ct2)) dB2);
+val ct2' = cterm_of @{theory} (term_of_dB [] (#T (rep_cterm ct2)) dB2);
*}
text {*
@@ -505,11 +504,11 @@
ML {*
val ct1 = @{cterm "%f. ((%f x. f (f (f x))) ((%f x. f (f (f (f x)))) f))"};
val (dB1, _) = Norm.type_NF (typing_of_term [] dummyf (term_of ct1));
-val ct1' = cterm_of (the_context ()) (term_of_dB [] (#T (rep_cterm ct1)) dB1);
+val ct1' = cterm_of @{theory} (term_of_dB [] (#T (rep_cterm ct1)) dB1);
val ct2 = @{cterm "%f x. (%x. f x x) ((%x. f x x) ((%x. f x x) ((%x. f x x) ((%x. f x x) ((%x. f x x) x)))))"};
val (dB2, _) = Norm.type_NF (typing_of_term [] dummyf (term_of ct2));
-val ct2' = cterm_of (the_context ()) (term_of_dB [] (#T (rep_cterm ct2)) dB2);
+val ct2' = cterm_of @{theory} (term_of_dB [] (#T (rep_cterm ct2)) dB2);
*}
end
diff -r 64a12f353c57 -r efc5f4806cd5 src/HOL/List.thy
--- a/src/HOL/List.thy Wed Jul 15 15:09:56 2009 +0200
+++ b/src/HOL/List.thy Fri Jul 17 10:07:15 2009 +0200
@@ -679,7 +679,7 @@
in
val list_eq_simproc =
- Simplifier.simproc (the_context ()) "list_eq" ["(xs::'a list) = ys"] (K list_eq);
+ Simplifier.simproc @{theory} "list_eq" ["(xs::'a list) = ys"] (K list_eq);
end;
@@ -3190,7 +3190,7 @@
begin
definition
-successor_int_def: "successor = (%i\int. i+1)"
+successor_int_def[simp]: "successor = (%i\int. i+1)"
instance
by intro_classes (simp_all add: successor_int_def)
diff -r 64a12f353c57 -r efc5f4806cd5 src/HOL/Modelcheck/EindhovenSyn.thy
--- a/src/HOL/Modelcheck/EindhovenSyn.thy Wed Jul 15 15:09:56 2009 +0200
+++ b/src/HOL/Modelcheck/EindhovenSyn.thy Fri Jul 17 10:07:15 2009 +0200
@@ -1,5 +1,4 @@
(* Title: HOL/Modelcheck/EindhovenSyn.thy
- ID: $Id$
Author: Olaf Mueller, Jan Philipps, Robert Sandner
Copyright 1997 TU Muenchen
*)
@@ -70,7 +69,7 @@
val pair_eta_expand = Thm.symmetric (mk_meta_eq (thm "split_eta"));
val pair_eta_expand_proc =
- Simplifier.simproc (the_context ()) "pair_eta_expand" ["f::'a*'b=>'c"]
+ Simplifier.simproc @{theory} "pair_eta_expand" ["f::'a*'b=>'c"]
(fn _ => fn _ => fn t => case t of Abs _ => SOME pair_eta_expand | _ => NONE);
val Eindhoven_ss =
diff -r 64a12f353c57 -r efc5f4806cd5 src/HOL/Modelcheck/MuckeSyn.thy
--- a/src/HOL/Modelcheck/MuckeSyn.thy Wed Jul 15 15:09:56 2009 +0200
+++ b/src/HOL/Modelcheck/MuckeSyn.thy Fri Jul 17 10:07:15 2009 +0200
@@ -1,5 +1,4 @@
(* Title: HOL/Modelcheck/MuckeSyn.thy
- ID: $Id$
Author: Tobias Hamberger
Copyright 1999 TU Muenchen
*)
@@ -119,7 +118,7 @@
local
- val move_thm = prove_goal (the_context ()) "[| a = b ==> P a; a = b |] ==> P b"
+ val move_thm = prove_goal @{theory} "[| a = b ==> P a; a = b |] ==> P b"
(fn prems => [cut_facts_tac prems 1, dtac sym 1, hyp_subst_tac 1,
REPEAT (resolve_tac prems 1)]);
@@ -214,7 +213,7 @@
val pair_eta_expand = Thm.symmetric (mk_meta_eq (thm "split_eta"));
val pair_eta_expand_proc =
- Simplifier.simproc (the_context ()) "pair_eta_expand" ["f::'a*'b=>'c"]
+ Simplifier.simproc @{theory} "pair_eta_expand" ["f::'a*'b=>'c"]
(fn _ => fn _ => fn t => case t of Abs _ => SOME pair_eta_expand | _ => NONE);
val Mucke_ss = @{simpset} addsimprocs [pair_eta_expand_proc] addsimps [Let_def];
diff -r 64a12f353c57 -r efc5f4806cd5 src/HOL/Nominal/Examples/Fsub.thy
--- a/src/HOL/Nominal/Examples/Fsub.thy Wed Jul 15 15:09:56 2009 +0200
+++ b/src/HOL/Nominal/Examples/Fsub.thy Fri Jul 17 10:07:15 2009 +0200
@@ -91,7 +91,7 @@
pairs of type-variables and types (this is sufficient for Part 1A). *}
text {* In order to state validity-conditions for typing-contexts, the notion of
- a @{text "domain"} of a typing-context is handy. *}
+ a @{text "dom"} of a typing-context is handy. *}
nominal_primrec
"tyvrs_of" :: "binding \ tyvrs set"
@@ -108,16 +108,16 @@
by auto
consts
- "ty_domain" :: "env \ tyvrs set"
+ "ty_dom" :: "env \ tyvrs set"
primrec
- "ty_domain [] = {}"
- "ty_domain (X#\) = (tyvrs_of X)\(ty_domain \)"
+ "ty_dom [] = {}"
+ "ty_dom (X#\) = (tyvrs_of X)\(ty_dom \)"
consts
- "trm_domain" :: "env \ vrs set"
+ "trm_dom" :: "env \ vrs set"
primrec
- "trm_domain [] = {}"
- "trm_domain (X#\) = (vrs_of X)\(trm_domain \)"
+ "trm_dom [] = {}"
+ "trm_dom (X#\) = (vrs_of X)\(trm_dom \)"
lemma vrs_of_eqvt[eqvt]:
fixes pi ::"tyvrs prm"
@@ -128,13 +128,13 @@
and "pi'\(vrs_of x) = vrs_of (pi'\x)"
by (nominal_induct x rule: binding.strong_induct) (simp_all add: tyvrs_of.simps eqvts)
-lemma domains_eqvt[eqvt]:
+lemma doms_eqvt[eqvt]:
fixes pi::"tyvrs prm"
and pi'::"vrs prm"
- shows "pi \(ty_domain \) = ty_domain (pi\\)"
- and "pi'\(ty_domain \) = ty_domain (pi'\\)"
- and "pi \(trm_domain \) = trm_domain (pi\\)"
- and "pi'\(trm_domain \) = trm_domain (pi'\\)"
+ shows "pi \(ty_dom \) = ty_dom (pi\\)"
+ and "pi'\(ty_dom \) = ty_dom (pi'\\)"
+ and "pi \(trm_dom \) = trm_dom (pi\\)"
+ and "pi'\(trm_dom \) = trm_dom (pi'\\)"
by (induct \) (simp_all add: eqvts)
lemma finite_vrs:
@@ -142,19 +142,19 @@
and "finite (vrs_of x)"
by (nominal_induct rule:binding.strong_induct, auto)
-lemma finite_domains:
- shows "finite (ty_domain \)"
- and "finite (trm_domain \)"
+lemma finite_doms:
+ shows "finite (ty_dom \)"
+ and "finite (trm_dom \)"
by (induct \, auto simp add: finite_vrs)
-lemma ty_domain_supp:
- shows "(supp (ty_domain \)) = (ty_domain \)"
- and "(supp (trm_domain \)) = (trm_domain \)"
-by (simp only: at_fin_set_supp at_tyvrs_inst at_vrs_inst finite_domains)+
+lemma ty_dom_supp:
+ shows "(supp (ty_dom \)) = (ty_dom \)"
+ and "(supp (trm_dom \)) = (trm_dom \)"
+by (simp only: at_fin_set_supp at_tyvrs_inst at_vrs_inst finite_doms)+
-lemma ty_domain_inclusion:
+lemma ty_dom_inclusion:
assumes a: "(TVarB X T)\set \"
- shows "X\(ty_domain \)"
+ shows "X\(ty_dom \)"
using a by (induct \, auto)
lemma ty_binding_existence:
@@ -163,8 +163,8 @@
using assms
by (nominal_induct a rule: binding.strong_induct, auto)
-lemma ty_domain_existence:
- assumes a: "X\(ty_domain \)"
+lemma ty_dom_existence:
+ assumes a: "X\(ty_dom \)"
shows "\T.(TVarB X T)\set \"
using a
apply (induct \, auto)
@@ -173,9 +173,9 @@
apply (auto simp add: ty_binding_existence)
done
-lemma domains_append:
- shows "ty_domain (\@\) = ((ty_domain \) \ (ty_domain \))"
- and "trm_domain (\@\) = ((trm_domain \) \ (trm_domain \))"
+lemma doms_append:
+ shows "ty_dom (\@\) = ((ty_dom \) \ (ty_dom \))"
+ and "trm_dom (\@\) = ((trm_dom \) \ (trm_dom \))"
by (induct \, auto)
lemma ty_vrs_prm_simp:
@@ -184,15 +184,15 @@
shows "pi\S = S"
by (induct S rule: ty.induct) (auto simp add: calc_atm)
-lemma fresh_ty_domain_cons:
+lemma fresh_ty_dom_cons:
fixes X::"tyvrs"
- shows "X\(ty_domain (Y#\)) = (X\(tyvrs_of Y) \ X\(ty_domain \))"
+ shows "X\(ty_dom (Y#\)) = (X\(tyvrs_of Y) \ X\(ty_dom \))"
apply (nominal_induct rule:binding.strong_induct)
apply (auto)
apply (simp add: fresh_def supp_def eqvts)
- apply (simp add: fresh_fin_insert [OF pt_tyvrs_inst at_tyvrs_inst fs_tyvrs_inst] finite_domains)
+ apply (simp add: fresh_fin_insert [OF pt_tyvrs_inst at_tyvrs_inst fs_tyvrs_inst] finite_doms)
apply (simp add: fresh_def supp_def eqvts)
- apply (simp add: fresh_fin_insert [OF pt_tyvrs_inst at_tyvrs_inst fs_tyvrs_inst] finite_domains)+
+ apply (simp add: fresh_fin_insert [OF pt_tyvrs_inst at_tyvrs_inst fs_tyvrs_inst] finite_doms)+
done
lemma tyvrs_fresh:
@@ -206,26 +206,26 @@
apply (fresh_guess)+
done
-lemma fresh_domain:
+lemma fresh_dom:
fixes X::"tyvrs"
assumes a: "X\\"
- shows "X\(ty_domain \)"
+ shows "X\(ty_dom \)"
using a
apply(induct \)
apply(simp add: fresh_set_empty)
-apply(simp only: fresh_ty_domain_cons)
+apply(simp only: fresh_ty_dom_cons)
apply(auto simp add: fresh_prod fresh_list_cons tyvrs_fresh)
done
text {* Not all lists of type @{typ "env"} are well-formed. One condition
requires that in @{term "TVarB X S#\"} all free variables of @{term "S"} must be
- in the @{term "ty_domain"} of @{term "\"}, that is @{term "S"} must be @{text "closed"}
+ in the @{term "ty_dom"} of @{term "\"}, that is @{term "S"} must be @{text "closed"}
in @{term "\"}. The set of free variables of @{term "S"} is the
@{text "support"} of @{term "S"}. *}
constdefs
"closed_in" :: "ty \ env \ bool" ("_ closed'_in _" [100,100] 100)
- "S closed_in \ \ (supp S)\(ty_domain \)"
+ "S closed_in \ \ (supp S)\(ty_dom \)"
lemma closed_in_eqvt[eqvt]:
fixes pi::"tyvrs prm"
@@ -251,10 +251,10 @@
shows "x \ T"
by (simp add: fresh_def supp_def ty_vrs_prm_simp)
-lemma ty_domain_vrs_prm_simp:
+lemma ty_dom_vrs_prm_simp:
fixes pi::"vrs prm"
and \::"env"
- shows "(ty_domain (pi\\)) = (ty_domain \)"
+ shows "(ty_dom (pi\\)) = (ty_dom \)"
apply(induct \)
apply (simp add: eqvts)
apply(simp add: tyvrs_vrs_prm_simp)
@@ -265,7 +265,7 @@
assumes a: "S closed_in \"
shows "(pi\S) closed_in (pi\\)"
using a
-by (simp add: closed_in_def ty_domain_vrs_prm_simp ty_vrs_prm_simp)
+by (simp add: closed_in_def ty_dom_vrs_prm_simp ty_vrs_prm_simp)
lemma fresh_vrs_of:
fixes x::"vrs"
@@ -273,16 +273,16 @@
by (nominal_induct b rule: binding.strong_induct)
(simp_all add: fresh_singleton [OF pt_vrs_inst at_vrs_inst] fresh_set_empty ty_vrs_fresh fresh_atm)
-lemma fresh_trm_domain:
+lemma fresh_trm_dom:
fixes x::"vrs"
- shows "x\ trm_domain \ = x\\"
+ shows "x\ trm_dom \ = x\\"
by (induct \)
(simp_all add: fresh_set_empty fresh_list_cons
fresh_fin_union [OF pt_vrs_inst at_vrs_inst fs_vrs_inst]
- finite_domains finite_vrs fresh_vrs_of fresh_list_nil)
+ finite_doms finite_vrs fresh_vrs_of fresh_list_nil)
-lemma closed_in_fresh: "(X::tyvrs) \ ty_domain \ \ T closed_in \ \ X \ T"
- by (auto simp add: closed_in_def fresh_def ty_domain_supp)
+lemma closed_in_fresh: "(X::tyvrs) \ ty_dom \ \ T closed_in \ \ X \ T"
+ by (auto simp add: closed_in_def fresh_def ty_dom_supp)
text {* Now validity of a context is a straightforward inductive definition. *}
@@ -290,15 +290,18 @@
valid_rel :: "env \ bool" ("\ _ ok" [100] 100)
where
valid_nil[simp]: "\ [] ok"
-| valid_consT[simp]: "\\ \ ok; X\(ty_domain \); T closed_in \\ \ \ (TVarB X T#\) ok"
-| valid_cons [simp]: "\\ \ ok; x\(trm_domain \); T closed_in \\ \ \ (VarB x T#\) ok"
+| valid_consT[simp]: "\\ \ ok; X\(ty_dom \); T closed_in \\ \ \ (TVarB X T#\) ok"
+| valid_cons [simp]: "\\ \ ok; x\(trm_dom \); T closed_in \\ \ \ (VarB x T#\) ok"
equivariance valid_rel
declare binding.inject [simp add]
declare trm.inject [simp add]
-inductive_cases validE[elim]: "\ (TVarB X T#\