# HG changeset patch # User paulson # Date 1556640212 -3600 # Node ID b21efbf6429208a8c6536dba13f92f19b3795ea5 # Parent e48c0b5897a6160d5c2817c7d750add34fae1c28 yet more de-applying diff -r e48c0b5897a6 -r b21efbf64292 src/HOL/Nonstandard_Analysis/HyperNat.thy --- a/src/HOL/Nonstandard_Analysis/HyperNat.thy Tue Apr 30 15:49:15 2019 +0100 +++ b/src/HOL/Nonstandard_Analysis/HyperNat.thy Tue Apr 30 17:03:32 2019 +0100 @@ -154,12 +154,14 @@ lemma hypnat_of_nat_Suc [simp]: "hypnat_of_nat (Suc n) = hypnat_of_nat n + 1" by transfer simp -lemma of_nat_eq_add [rule_format]: "\d::hypnat. of_nat m = of_nat n + d \ d \ range of_nat" - apply (induct n) - apply (auto simp add: add.assoc) - apply (case_tac x) - apply (auto simp add: add.commute [of 1]) - done +lemma of_nat_eq_add: + fixes d::hypnat + shows "of_nat m = of_nat n + d \ d \ range of_nat" +proof (induct n arbitrary: d) + case (Suc n) + then show ?case + by (metis Nats_def Nats_eq_Standard Standard_simps(4) hypnat_diff_add_inverse of_nat_in_Nats) +qed auto lemma Nats_diff [simp]: "a \ Nats \ b \ Nats \ a - b \ Nats" for a b :: hypnat by (simp add: Nats_eq_Standard) @@ -224,37 +226,22 @@ by (simp add: HNatInfinite_def) lemma Nats_downward_closed: "x \ Nats \ y \ x \ y \ Nats" for x y :: hypnat - apply (simp only: linorder_not_less [symmetric]) - apply (erule contrapos_np) - apply (drule HNatInfinite_not_Nats_iff [THEN iffD2]) - apply (erule (1) Nats_less_HNatInfinite) - done + using HNatInfinite_not_Nats_iff Nats_le_HNatInfinite by fastforce lemma HNatInfinite_upward_closed: "x \ HNatInfinite \ x \ y \ y \ HNatInfinite" - apply (simp only: HNatInfinite_not_Nats_iff) - apply (erule contrapos_nn) - apply (erule (1) Nats_downward_closed) - done + using HNatInfinite_not_Nats_iff Nats_downward_closed by blast lemma HNatInfinite_add: "x \ HNatInfinite \ x + y \ HNatInfinite" - apply (erule HNatInfinite_upward_closed) - apply (rule hypnat_le_add1) - done + using HNatInfinite_upward_closed hypnat_le_add1 by blast lemma HNatInfinite_add_one: "x \ HNatInfinite \ x + 1 \ HNatInfinite" by (rule HNatInfinite_add) -lemma HNatInfinite_diff: "x \ HNatInfinite \ y \ Nats \ x - y \ HNatInfinite" - apply (frule (1) Nats_le_HNatInfinite) - apply (simp only: HNatInfinite_not_Nats_iff) - apply (erule contrapos_nn) - apply (drule (1) Nats_add, simp) - done +lemma HNatInfinite_diff: "\x \ HNatInfinite; y \ Nats\ \ x - y \ HNatInfinite" + by (metis HNatInfinite_not_Nats_iff Nats_add Nats_le_HNatInfinite le_add_diff_inverse) lemma HNatInfinite_is_Suc: "x \ HNatInfinite \ \y. x = y + 1" for x :: hypnat - apply (rule_tac x = "x - (1::hypnat) " in exI) - apply (simp add: Nats_le_HNatInfinite) - done + using hypnat_gt_zero_iff2 zero_less_HNatInfinite by blast subsection \Existence of an infinite hypernatural number\ @@ -308,32 +295,29 @@ text \\<^term>\HNatInfinite = {N. \n \ Nats. n < N}\\ -(*??delete? similar reasoning in hypnat_omega_gt_SHNat above*) -lemma HNatInfinite_FreeUltrafilterNat_lemma: - assumes "\N::nat. eventually (\n. f n \ N) \" - shows "eventually (\n. N < f n) \" - apply (induct N) - using assms - apply (drule_tac x = 0 in spec, simp) - using assms - apply (drule_tac x = "Suc N" in spec) - apply (auto elim: eventually_elim2) - done +text\unused, but possibly interesting\ +lemma HNatInfinite_FreeUltrafilterNat_eventually: + assumes "\k::nat. eventually (\n. f n \ k) \" + shows "eventually (\n. m < f n) \" +proof (induct m) + case 0 + then show ?case + using assms eventually_mono by fastforce +next + case (Suc m) + then show ?case + using assms [of "Suc m"] eventually_elim2 by fastforce +qed lemma HNatInfinite_iff: "HNatInfinite = {N. \n \ Nats. n < N}" - apply (safe intro!: Nats_less_HNatInfinite) - apply (auto simp add: HNatInfinite_def) - done + using HNatInfinite_def Nats_less_HNatInfinite by auto subsubsection \Alternative Characterization of \<^term>\HNatInfinite\ using Free Ultrafilter\ lemma HNatInfinite_FreeUltrafilterNat: "star_n X \ HNatInfinite \ \u. eventually (\n. u < X n) \" - apply (auto simp add: HNatInfinite_iff SHNat_eq) - apply (drule_tac x="star_of u" in spec, simp) - apply (simp add: star_of_def star_less_def starP2_star_n) - done + by (metis (full_types) starP2_star_of starP_star_n star_less_def star_of_less_HNatInfinite) lemma FreeUltrafilterNat_HNatInfinite: "\u. eventually (\n. u < X n) \ \ star_n X \ HNatInfinite" diff -r e48c0b5897a6 -r b21efbf64292 src/HOL/Nonstandard_Analysis/NatStar.thy --- a/src/HOL/Nonstandard_Analysis/NatStar.thy Tue Apr 30 15:49:15 2019 +0100 +++ b/src/HOL/Nonstandard_Analysis/NatStar.thy Tue Apr 30 17:03:32 2019 +0100 @@ -15,33 +15,49 @@ by (simp add: hypnat_omega_def starfun_def star_of_def Ifun_star_n) lemma starset_n_Un: "*sn* (\n. (A n) \ (B n)) = *sn* A \ *sn* B" - apply (simp add: starset_n_def star_n_eq_starfun_whn Un_def) - apply (rule_tac x=whn in spec, transfer, simp) - done +proof - + have "\N. Iset ((*f* (\n. {x. x \ A n \ x \ B n})) N) = + {x. x \ Iset ((*f* A) N) \ x \ Iset ((*f* B) N)}" + by transfer simp + then show ?thesis + by (simp add: starset_n_def star_n_eq_starfun_whn Un_def) +qed lemma InternalSets_Un: "X \ InternalSets \ Y \ InternalSets \ X \ Y \ InternalSets" by (auto simp add: InternalSets_def starset_n_Un [symmetric]) lemma starset_n_Int: "*sn* (\n. A n \ B n) = *sn* A \ *sn* B" - apply (simp add: starset_n_def star_n_eq_starfun_whn Int_def) - apply (rule_tac x=whn in spec, transfer, simp) - done +proof - + have "\N. Iset ((*f* (\n. {x. x \ A n \ x \ B n})) N) = + {x. x \ Iset ((*f* A) N) \ x \ Iset ((*f* B) N)}" + by transfer simp + then show ?thesis + by (simp add: starset_n_def star_n_eq_starfun_whn Int_def) +qed lemma InternalSets_Int: "X \ InternalSets \ Y \ InternalSets \ X \ Y \ InternalSets" by (auto simp add: InternalSets_def starset_n_Int [symmetric]) lemma starset_n_Compl: "*sn* ((\n. - A n)) = - ( *sn* A)" - apply (simp add: starset_n_def star_n_eq_starfun_whn Compl_eq) - apply (rule_tac x=whn in spec, transfer, simp) - done +proof - + have "\N. Iset ((*f* (\n. {x. x \ A n})) N) = + {x. x \ Iset ((*f* A) N)}" + by transfer simp + then show ?thesis + by (simp add: starset_n_def star_n_eq_starfun_whn Compl_eq) +qed lemma InternalSets_Compl: "X \ InternalSets \ - X \ InternalSets" by (auto simp add: InternalSets_def starset_n_Compl [symmetric]) lemma starset_n_diff: "*sn* (\n. (A n) - (B n)) = *sn* A - *sn* B" - apply (simp add: starset_n_def star_n_eq_starfun_whn set_diff_eq) - apply (rule_tac x=whn in spec, transfer, simp) - done +proof - + have "\N. Iset ((*f* (\n. {x. x \ A n \ x \ B n})) N) = + {x. x \ Iset ((*f* A) N) \ x \ Iset ((*f* B) N)}" + by transfer simp + then show ?thesis + by (simp add: starset_n_def star_n_eq_starfun_whn set_diff_eq) +qed lemma InternalSets_diff: "X \ InternalSets \ Y \ InternalSets \ X - Y \ InternalSets" by (auto simp add: InternalSets_def starset_n_diff [symmetric]) @@ -59,9 +75,7 @@ by (auto simp add: InternalSets_def starset_starset_n_eq) lemma InternalSets_UNIV_diff: "X \ InternalSets \ UNIV - X \ InternalSets" - apply (subgoal_tac "UNIV - X = - X") - apply (auto intro: InternalSets_Compl) - done + by (simp add: InternalSets_Compl diff_eq) subsection \Nonstandard Extensions of Functions\ @@ -104,10 +118,7 @@ lemma starfun_inverse_real_of_nat_eq: "N \ HNatInfinite \ ( *f* (\x::nat. inverse (real x))) N = inverse (hypreal_of_hypnat N)" - apply (rule_tac f1 = inverse in starfun_o2 [THEN subst]) - apply (subgoal_tac "hypreal_of_hypnat N \ 0") - apply (simp_all add: zero_less_HNatInfinite starfunNat_real_of_nat) - done + by (metis of_hypnat_def starfun_inverse2) text \Internal functions -- some redundancy with \*f*\ now.\ @@ -144,10 +155,7 @@ lemma starfunNat_inverse_real_of_nat_Infinitesimal [simp]: "N \ HNatInfinite \ ( *f* (\x. inverse (real x))) N \ Infinitesimal" - apply (rule_tac f1 = inverse in starfun_o2 [THEN subst]) - apply (subgoal_tac "hypreal_of_hypnat N \ 0") - apply (simp_all add: zero_less_HNatInfinite starfunNat_real_of_nat) - done + using starfun_inverse_real_of_nat_eq by auto subsection \Nonstandard Characterization of Induction\ @@ -166,23 +174,22 @@ lemma starP2_eq_iff2: "( *p2* (\x y. x = y)) X Y \ X = Y" by (simp add: starP2_eq_iff) -lemma nonempty_nat_set_Least_mem: "c \ S \ (LEAST n. n \ S) \ S" - for S :: "nat set" - by (erule LeastI) +lemma nonempty_set_star_has_least_lemma: + "\n\S. \m\S. n \ m" if "S \ {}" for S :: "nat set" +proof + show "\m\S. (LEAST n. n \ S) \ m" + by (simp add: Least_le) + show "(LEAST n. n \ S) \ S" + by (meson that LeastI_ex equals0I) +qed lemma nonempty_set_star_has_least: "\S::nat set star. Iset S \ {} \ \n \ Iset S. \m \ Iset S. n \ m" - apply (transfer empty_def) - apply (rule_tac x="LEAST n. n \ S" in bexI) - apply (simp add: Least_le) - apply (rule LeastI_ex, auto) - done + using nonempty_set_star_has_least_lemma by (transfer empty_def) lemma nonempty_InternalNatSet_has_least: "S \ InternalSets \ S \ {} \ \n \ S. \m \ S. n \ m" for S :: "hypnat set" - apply (clarsimp simp add: InternalSets_def starset_n_def) - apply (erule nonempty_set_star_has_least) - done + by (force simp add: InternalSets_def starset_n_def dest!: nonempty_set_star_has_least) text \Goldblatt, page 129 Thm 11.3.2.\ lemma internal_induct_lemma: diff -r e48c0b5897a6 -r b21efbf64292 src/HOL/Nonstandard_Analysis/StarDef.thy --- a/src/HOL/Nonstandard_Analysis/StarDef.thy Tue Apr 30 15:49:15 2019 +0100 +++ b/src/HOL/Nonstandard_Analysis/StarDef.thy Tue Apr 30 17:03:32 2019 +0100 @@ -14,11 +14,8 @@ where "\ = (SOME U. freeultrafilter U)" lemma freeultrafilter_FreeUltrafilterNat: "freeultrafilter \" - apply (unfold FreeUltrafilterNat_def) - apply (rule someI_ex) - apply (rule freeultrafilter_Ex) - apply (rule infinite_UNIV_nat) - done + unfolding FreeUltrafilterNat_def + by (simp add: freeultrafilter_Ex someI_ex) interpretation FreeUltrafilterNat: freeultrafilter \ by (rule freeultrafilter_FreeUltrafilterNat) @@ -42,16 +39,10 @@ by (cases x) (auto simp: star_n_def star_def elim: quotientE) lemma all_star_eq: "(\x. P x) \ (\X. P (star_n X))" - apply auto - apply (rule_tac x = x in star_cases) - apply simp - done + by (metis star_cases) lemma ex_star_eq: "(\x. P x) \ (\X. P (star_n X))" - apply auto - apply (rule_tac x=x in star_cases) - apply auto - done + by (metis star_cases) text \Proving that \<^term>\starrel\ is an equivalence relation.\ @@ -599,12 +590,16 @@ subsection \Ordering and lattice classes\ instance star :: (order) order - apply intro_classes - apply (transfer, rule less_le_not_le) - apply (transfer, rule order_refl) - apply (transfer, erule (1) order_trans) - apply (transfer, erule (1) order_antisym) - done +proof + show "\x y::'a star. (x < y) = (x \ y \ \ y \ x)" + by transfer (rule less_le_not_le) + show "\x::'a star. x \ x" + by transfer (rule order_refl) + show "\x y z::'a star. \x \ y; y \ z\ \ x \ z" + by transfer (rule order_trans) + show "\x y::'a star. \x \ y; y \ x\ \ x = y" + by transfer (rule order_antisym) +qed instantiation star :: (semilattice_inf) semilattice_inf begin @@ -639,16 +634,12 @@ by (intro_classes, transfer, rule linorder_linear) lemma star_max_def [transfer_unfold]: "max = *f2* max" - apply (rule ext, rule ext) - apply (unfold max_def, transfer, fold max_def) - apply (rule refl) - done + unfolding max_def + by (intro ext, transfer, simp) lemma star_min_def [transfer_unfold]: "min = *f2* min" - apply (rule ext, rule ext) - apply (unfold min_def, transfer, fold min_def) - apply (rule refl) - done + unfolding min_def + by (intro ext, transfer, simp) lemma Standard_max [simp]: "x \ Standard \ y \ Standard \ max x y \ Standard" by (simp add: star_max_def) @@ -928,10 +919,9 @@ by (erule finite_induct) simp_all instance star :: (finite) finite - apply intro_classes - apply (subst starset_UNIV [symmetric]) - apply (subst starset_finite [OF finite]) - apply (rule finite_imageI [OF finite]) - done +proof intro_classes + show "finite (UNIV::'a star set)" + by (metis starset_UNIV finite finite_imageI starset_finite) +qed end