tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
authorimmler
Wed Jul 17 13:34:21 2013 +0200 (2013-07-17)
changeset 526818cc7f76b827a
parent 52680 c16f35e5a5aa
child 52691 f06b403a7dcd
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
src/HOL/Library/Diagonal_Subsequence.thy
src/HOL/Probability/Projective_Limit.thy
     1.1 --- a/src/HOL/Library/Diagonal_Subsequence.thy	Tue Jul 16 23:34:33 2013 +0200
     1.2 +++ b/src/HOL/Library/Diagonal_Subsequence.thy	Wed Jul 17 13:34:21 2013 +0200
     1.3 @@ -11,66 +11,61 @@
     1.4    assumes ex_subseq: "\<And>n s. subseq s \<Longrightarrow> \<exists>r'. subseq r' \<and> P n (s o r')"
     1.5  begin
     1.6  
     1.7 +definition reduce where "reduce s n = (SOME r'. subseq r' \<and> P n (s o r'))"
     1.8 +
     1.9 +lemma subseq_reduce[intro, simp]:
    1.10 +  "subseq s \<Longrightarrow> subseq (reduce s n)"
    1.11 +  unfolding reduce_def by (rule someI2_ex[OF ex_subseq]) auto
    1.12 +
    1.13 +lemma reduce_holds:
    1.14 +  "subseq s \<Longrightarrow> P n (s o reduce s n)"
    1.15 +  unfolding reduce_def by (rule someI2_ex[OF ex_subseq]) (auto simp: o_def)
    1.16 +
    1.17  primrec seqseq where
    1.18    "seqseq 0 = id"
    1.19 -| "seqseq (Suc n) = seqseq n o (SOME r'. subseq r' \<and> P n (seqseq n o r'))"
    1.20 +| "seqseq (Suc n) = seqseq n o reduce (seqseq n) n"
    1.21  
    1.22 -lemma seqseq_ex:
    1.23 -  shows "subseq (seqseq n) \<and>
    1.24 -  (\<exists>r'. seqseq (Suc n) = seqseq n o r' \<and> subseq r' \<and> P n (seqseq n o r'))"
    1.25 +lemma subseq_seqseq[intro, simp]: "subseq (seqseq n)"
    1.26  proof (induct n)
    1.27 -  case 0
    1.28 -  let ?P = "\<lambda>r'. subseq r' \<and> P 0 r'"
    1.29 -  let ?r = "Eps ?P"
    1.30 -  have "?P ?r" using ex_subseq[of id 0] by (intro someI_ex[of ?P]) (auto simp: subseq_def)
    1.31 -  thus ?case by (auto simp: subseq_def)
    1.32 -next
    1.33 -  case (Suc n)
    1.34 -  then obtain r' where
    1.35 -    Suc': "seqseq (Suc n) = seqseq n \<circ> r'" "subseq (seqseq n)" "subseq r'"
    1.36 -      "P n (seqseq n o r')"
    1.37 -    by blast
    1.38 -  let ?P = "\<lambda>r'a. subseq (r'a ) \<and> P (Suc n) (seqseq n o r' o r'a)"
    1.39 -  let ?r = "Eps ?P"
    1.40 -  have "?P ?r" using ex_subseq[of "seqseq n o r'" "Suc n"] Suc'
    1.41 -    by (intro someI_ex[of ?P]) (auto intro: subseq_o simp: o_assoc)
    1.42 -  moreover have "seqseq (Suc (Suc n)) = seqseq n \<circ> r' \<circ> ?r"
    1.43 -    by (subst seqseq.simps) (simp only: Suc' o_assoc)
    1.44 -  moreover note subseq_o[OF `subseq (seqseq n)` `subseq r'`]
    1.45 -  ultimately show ?case unfolding Suc' by (auto simp: o_def)
    1.46 +  case (Suc n) thus ?case by (subst seqseq.simps) (auto simp: subseq_reduce intro!: subseq_o)
    1.47 +qed (simp add: subseq_def)
    1.48 +
    1.49 +lemma seqseq_holds:
    1.50 +  "P n (seqseq (Suc n))"
    1.51 +proof -
    1.52 +  have "P n (seqseq n o reduce (seqseq n) n)"
    1.53 +    by (intro reduce_holds subseq_seqseq)
    1.54 +  thus ?thesis by simp
    1.55  qed
    1.56  
    1.57 -lemma subseq_seqseq:
    1.58 -  shows "subseq (seqseq n)" using seqseq_ex[OF assms] by auto
    1.59 -
    1.60 -definition reducer where "reducer n = (SOME r'. subseq r' \<and> P n (seqseq n o r'))"
    1.61 -
    1.62 -lemma subseq_reducer: "subseq (reducer n)" and reducer_reduces: "P n (seqseq n o reducer n)"
    1.63 -  unfolding atomize_conj unfolding reducer_def using subseq_seqseq
    1.64 -  by (rule someI_ex[OF ex_subseq])
    1.65 -
    1.66 -lemma seqseq_reducer[simp]:
    1.67 -  "seqseq (Suc n) = seqseq n o reducer n"
    1.68 -  by (simp add: reducer_def)
    1.69 -
    1.70 -declare seqseq.simps(2)[simp del]
    1.71 -
    1.72  definition diagseq where "diagseq i = seqseq i i"
    1.73  
    1.74 +lemma subseq_mono: "subseq f \<Longrightarrow> a \<le> b \<Longrightarrow> f a \<le> f b"
    1.75 +  by (metis le_eq_less_or_eq subseq_mono)
    1.76 +
    1.77 +lemma subseq_strict_mono: "subseq f \<Longrightarrow> a < b \<Longrightarrow> f a < f b"
    1.78 +  by (simp add: subseq_def)
    1.79 +
    1.80  lemma diagseq_mono: "diagseq n < diagseq (Suc n)"
    1.81 -  unfolding diagseq_def seqseq_reducer o_def
    1.82 -  by (metis subseq_mono[OF subseq_seqseq] less_le_trans lessI seq_suble subseq_reducer)
    1.83 +proof -
    1.84 +  have "diagseq n < seqseq n (Suc n)"
    1.85 +    using subseq_seqseq[of n] by (simp add: diagseq_def subseq_def)
    1.86 +  also have "\<dots> \<le> seqseq n (reduce (seqseq n) n (Suc n))"
    1.87 +    by (auto intro: subseq_mono seq_suble)
    1.88 +  also have "\<dots> = diagseq (Suc n)" by (simp add: diagseq_def)
    1.89 +  finally show ?thesis .
    1.90 +qed
    1.91  
    1.92  lemma subseq_diagseq: "subseq diagseq"
    1.93    using diagseq_mono by (simp add: subseq_Suc_iff diagseq_def)
    1.94  
    1.95  primrec fold_reduce where
    1.96    "fold_reduce n 0 = id"
    1.97 -| "fold_reduce n (Suc k) = fold_reduce n k o reducer (n + k)"
    1.98 +| "fold_reduce n (Suc k) = fold_reduce n k o reduce (seqseq (n + k)) (n + k)"
    1.99  
   1.100 -lemma subseq_fold_reduce: "subseq (fold_reduce n k)"
   1.101 +lemma subseq_fold_reduce[intro, simp]: "subseq (fold_reduce n k)"
   1.102  proof (induct k)
   1.103 -  case (Suc k) from subseq_o[OF this subseq_reducer] show ?case by (simp add: o_def)
   1.104 +  case (Suc k) from subseq_o[OF this subseq_reduce] show ?case by (simp add: o_def)
   1.105  qed (simp add: subseq_def)
   1.106  
   1.107  lemma ex_subseq_reduce_index: "seqseq (n + k) = seqseq n o fold_reduce n k"
   1.108 @@ -100,12 +95,23 @@
   1.109  
   1.110  lemma subseq_diagonal_rest: "subseq (\<lambda>x. fold_reduce k x (k + x))"
   1.111    unfolding subseq_Suc_iff fold_reduce.simps o_def
   1.112 -  by (metis subseq_mono[OF subseq_fold_reduce] less_le_trans lessI add_Suc_right seq_suble
   1.113 -      subseq_reducer)
   1.114 +proof
   1.115 +  fix n
   1.116 +  have "fold_reduce k n (k + n) < fold_reduce k n (k + Suc n)" (is "?lhs < _")
   1.117 +    by (auto intro: subseq_strict_mono)
   1.118 +  also have "\<dots> \<le> fold_reduce k n (reduce (seqseq (k + n)) (k + n) (k + Suc n))"
   1.119 +    by (rule subseq_mono) (auto intro!: seq_suble subseq_mono)
   1.120 +  finally show "?lhs < \<dots>" .
   1.121 +qed
   1.122  
   1.123  lemma diagseq_seqseq: "diagseq o (op + k) = (seqseq k o (\<lambda>x. fold_reduce k x (k + x)))"
   1.124    by (auto simp: o_def diagseq_add)
   1.125  
   1.126 +lemma diagseq_holds:
   1.127 +  assumes subseq_stable: "\<And>r s n. subseq r \<Longrightarrow> P n s \<Longrightarrow> P n (s o r)"
   1.128 +  shows "P k (diagseq o (op + (Suc k)))"
   1.129 +  unfolding diagseq_seqseq by (intro subseq_stable subseq_diagonal_rest seqseq_holds)
   1.130 +
   1.131  end
   1.132  
   1.133  end
     2.1 --- a/src/HOL/Probability/Projective_Limit.thy	Tue Jul 16 23:34:33 2013 +0200
     2.2 +++ b/src/HOL/Probability/Projective_Limit.thy	Wed Jul 17 13:34:21 2013 +0200
     2.3 @@ -77,25 +77,20 @@
     2.4  
     2.5  lemma (in finmap_seqs_into_compact) diagonal_tendsto: "\<exists>l. (\<lambda>i. (f (diagseq i))\<^isub>F n) ----> l"
     2.6  proof -
     2.7 -  have "\<And>i n0. (f o seqseq i) i = f (diagseq i)" unfolding diagseq_def by simp
     2.8 -  from reducer_reduces obtain l where l: "(\<lambda>i. ((f \<circ> seqseq (Suc n)) i)\<^isub>F n) ----> l"
     2.9 -    unfolding seqseq_reducer
    2.10 -  by auto
    2.11 -  have "(\<lambda>i. (f (diagseq (i + Suc n)))\<^isub>F n) =
    2.12 -    (\<lambda>i. ((f o (diagseq o (op + (Suc n)))) i)\<^isub>F n)" by (simp add: add_commute)
    2.13 -  also have "\<dots> =
    2.14 -    (\<lambda>i. ((f o ((seqseq (Suc n) o (\<lambda>x. fold_reduce (Suc n) x (Suc n + x))))) i)\<^isub>F n)"
    2.15 -    unfolding diagseq_seqseq by simp
    2.16 -  also have "\<dots> = (\<lambda>i. ((f o ((seqseq (Suc n)))) i)\<^isub>F n) o (\<lambda>x. fold_reduce (Suc n) x (Suc n + x))"
    2.17 -    by (simp add: o_def)
    2.18 -  also have "\<dots> ----> l"
    2.19 -  proof (rule LIMSEQ_subseq_LIMSEQ[OF _ subseq_diagonal_rest], rule tendstoI)
    2.20 -    fix e::real assume "0 < e"
    2.21 -    from tendstoD[OF l `0 < e`]
    2.22 -    show "eventually (\<lambda>x. dist (((f \<circ> seqseq (Suc n)) x)\<^isub>F n) l < e)
    2.23 -      sequentially" .
    2.24 +  obtain l where "(\<lambda>i. ((f o (diagseq o op + (Suc n))) i)\<^isub>F n) ----> l"
    2.25 +  proof (atomize_elim, rule diagseq_holds)
    2.26 +    fix r s n
    2.27 +    assume "subseq r"
    2.28 +    assume "\<exists>l. (\<lambda>i. ((f \<circ> s) i)\<^isub>F n) ----> l"
    2.29 +    then obtain l where "((\<lambda>i. (f i)\<^isub>F n) o s) ----> l"
    2.30 +      by (auto simp: o_def)
    2.31 +    hence "((\<lambda>i. (f i)\<^isub>F n) o s o r) ----> l" using `subseq r`
    2.32 +      by (rule LIMSEQ_subseq_LIMSEQ)
    2.33 +    thus "\<exists>l. (\<lambda>i. ((f \<circ> (s \<circ> r)) i)\<^isub>F n) ----> l" by (auto simp add: o_def)
    2.34    qed
    2.35 -  finally show ?thesis by (intro exI) (rule LIMSEQ_offset)
    2.36 +  hence "(\<lambda>i. ((f (diagseq (i + Suc n))))\<^isub>F n) ----> l" by (simp add: ac_simps)
    2.37 +  hence "(\<lambda>i. (f (diagseq i))\<^isub>F n) ----> l" by (rule LIMSEQ_offset)
    2.38 +  thus ?thesis ..
    2.39  qed
    2.40  
    2.41  subsection {* Daniell-Kolmogorov Theorem *}