# HG changeset patch # User huffman # Date 1268265421 28800 # Node ID 5007843dae335a830f60aab07fec35b583dd26d5 # Parent 29cb504abbb540e824ebcd8f8a4a1b11e93eb1bc convert HOL-Probability to use Nat_Bijection library diff -r 29cb504abbb5 -r 5007843dae33 src/HOL/Probability/Borel.thy --- a/src/HOL/Probability/Borel.thy Wed Mar 10 15:38:33 2010 -0800 +++ b/src/HOL/Probability/Borel.thy Wed Mar 10 15:57:01 2010 -0800 @@ -186,20 +186,20 @@ definition nat_to_rat_surj :: "nat \ rat" where - "nat_to_rat_surj n = (let (i,j) = nat_to_nat2 n - in Fract (nat_to_int_bij i) (nat_to_int_bij j))" + "nat_to_rat_surj n = (let (i,j) = prod_decode n + in Fract (int_decode i) (int_decode j))" lemma nat_to_rat_surj: "surj nat_to_rat_surj" proof (auto simp add: surj_def nat_to_rat_surj_def) fix y - show "\x. y = (\(i, j). Fract (nat_to_int_bij i) (nat_to_int_bij j)) (nat_to_nat2 x)" + show "\x. y = (\(i, j). Fract (int_decode i) (int_decode j)) (prod_decode x)" proof (cases y) case (Fract a b) - obtain i where i: "nat_to_int_bij i = a" using surj_nat_to_int_bij + obtain i where i: "int_decode i = a" using surj_int_decode by (metis surj_def) - obtain j where j: "nat_to_int_bij j = b" using surj_nat_to_int_bij + obtain j where j: "int_decode j = b" using surj_int_decode by (metis surj_def) - obtain n where n: "nat_to_nat2 n = (i,j)" using nat_to_nat2_surj + obtain n where n: "prod_decode n = (i,j)" using surj_prod_decode by (metis surj_def) from Fract i j n show ?thesis diff -r 29cb504abbb5 -r 5007843dae33 src/HOL/Probability/Caratheodory.thy --- a/src/HOL/Probability/Caratheodory.thy Wed Mar 10 15:38:33 2010 -0800 +++ b/src/HOL/Probability/Caratheodory.thy Wed Mar 10 15:57:01 2010 -0800 @@ -816,9 +816,9 @@ by (simp add: eqe) finally show ?thesis using Series.summable_le2 [OF 1 2] by auto qed - def C \ "(split BB) o nat_to_nat2" + def C \ "(split BB) o prod_decode" have C: "!!n. C n \ sets M" - apply (rule_tac p="nat_to_nat2 n" in PairE) + apply (rule_tac p="prod_decode n" in PairE) apply (simp add: C_def) apply (metis BB subsetD rangeI) done @@ -828,11 +828,10 @@ assume x: "x \ A i" with sbBB [of i] obtain j where "x \ BB i j" by blast - thus "\i. x \ split BB (nat_to_nat2 i)" - by (metis nat_to_nat2_surj internal_split_def prod.cases - prod_case_split surj_f_inv_f) + thus "\i. x \ split BB (prod_decode i)" + by (metis prod_encode_inverse prod.cases prod_case_split) qed - have "(f \ C) = (f \ (\(x, y). BB x y)) \ nat_to_nat2" + have "(f \ C) = (f \ (\(x, y). BB x y)) \ prod_decode" by (rule ext) (auto simp add: C_def) also have "... sums suminf ll" proof (rule suminf_2dimen) diff -r 29cb504abbb5 -r 5007843dae33 src/HOL/Probability/SeriesPlus.thy --- a/src/HOL/Probability/SeriesPlus.thy Wed Mar 10 15:38:33 2010 -0800 +++ b/src/HOL/Probability/SeriesPlus.thy Wed Mar 10 15:57:01 2010 -0800 @@ -1,5 +1,5 @@ theory SeriesPlus - imports Complex_Main Nat_Int_Bij + imports Complex_Main Nat_Bijection begin text{*From the Hurd/Coble measure theory development, translated by Lawrence Paulson.*} @@ -16,7 +16,7 @@ assumes f_nneg: "!!m n. 0 \ f(m,n)" and fsums: "!!m. (\n. f (m,n)) sums (g m)" and sumg: "summable g" - shows "(f o nat_to_nat2) sums suminf g" + shows "(f o prod_decode) sums suminf g" proof (simp add: sums_def) { fix x @@ -31,18 +31,18 @@ thus "0 \ g m" using fsums [of m] by (auto simp add: sums_iff) qed - show "(\n. \x = 0.. suminf g" + show "(\n. \x = 0.. suminf g" proof (rule increasing_LIMSEQ, simp add: f_nneg) fix n - def i \ "Max (Domain (nat_to_nat2 ` {0.. "Max (Range (nat_to_nat2 ` {0.. ({0..i} \ {0..j})" + def i \ "Max (Domain (prod_decode ` {0.. "Max (Range (prod_decode ` {0.. ({0..i} \ {0..j})" by (force simp add: i_def j_def intro: finite_imageI Max_ge finite_Domain finite_Range) - have "(\x = 0..x = 0.. setsum f ({0..i} \ {0..j})" by (rule setsum_mono2) (auto simp add: ij) also have "... = setsum (\m. setsum (\n. f (m,n)) {0..j}) {0..x = 0.. setsum g {0..x = 0.. setsum g {0.. suminf g" by (rule series_pos_le [OF sumg]) (simp add: g_nneg) - finally show "(\x = 0.. suminf g" . + finally show "(\x = 0.. suminf g" . next fix e :: real assume e: "0 < e" @@ -99,26 +99,25 @@ by auto have finite_IJ: "finite IJ" by (simp add: IJ_def) - def NIJ \ "Max (nat_to_nat2 -` IJ)" - have IJsb: "IJ \ nat_to_nat2 ` {0..NIJ}" + def NIJ \ "Max (prod_decode -` IJ)" + have IJsb: "IJ \ prod_decode ` {0..NIJ}" proof (auto simp add: NIJ_def) fix i j assume ij:"(i,j) \ IJ" - hence "(i,j) = nat_to_nat2 (inv nat_to_nat2 (i,j))" - by (metis nat_to_nat2_surj surj_f_inv_f) - thus "(i,j) \ nat_to_nat2 ` {0..Max (nat_to_nat2 -` IJ)}" + hence "(i,j) = prod_decode (prod_encode (i,j))" + by simp + thus "(i,j) \ prod_decode ` {0..Max (prod_decode -` IJ)}" by (rule image_eqI) - (simp add: ij finite_vimageI [OF finite_IJ nat_to_nat2_inj] - nat_to_nat2_surj surj_f_inv_f) + (simp add: ij finite_vimageI [OF finite_IJ inj_prod_decode]) qed - have "setsum f IJ \ setsum f (nat_to_nat2 `{0..NIJ})" + have "setsum f IJ \ setsum f (prod_decode `{0..NIJ})" by (rule setsum_mono2) (auto simp add: IJsb) - also have "... = (\k = 0..NIJ. f (nat_to_nat2 k))" - by (simp add: setsum_reindex subset_inj_on [OF nat_to_nat2_inj subset_UNIV]) - also have "... = (\k = 0..k = 0..NIJ. f (prod_decode k))" + by (simp add: setsum_reindex inj_prod_decode) + also have "... = (\k = 0.. (\k = 0..n. suminf g \ (\x = 0.. (\k = 0..n. suminf g \ (\x = 0..