src/HOL/Library/Diagonal_Subsequence.thy
changeset 66447 a1f5c5c26fa6
parent 60500 903bb1495239
child 67091 1393c2340eec
     1.1 --- a/src/HOL/Library/Diagonal_Subsequence.thy	Thu Aug 17 14:40:42 2017 +0200
     1.2 +++ b/src/HOL/Library/Diagonal_Subsequence.thy	Thu Aug 17 14:52:56 2017 +0200
     1.3 @@ -8,28 +8,28 @@
     1.4  
     1.5  locale subseqs =
     1.6    fixes P::"nat\<Rightarrow>(nat\<Rightarrow>nat)\<Rightarrow>bool"
     1.7 -  assumes ex_subseq: "\<And>n s. subseq s \<Longrightarrow> \<exists>r'. subseq r' \<and> P n (s o r')"
     1.8 +  assumes ex_subseq: "\<And>n s. strict_mono (s::nat\<Rightarrow>nat) \<Longrightarrow> \<exists>r'. strict_mono r' \<and> P n (s o r')"
     1.9  begin
    1.10  
    1.11 -definition reduce where "reduce s n = (SOME r'. subseq r' \<and> P n (s o r'))"
    1.12 +definition reduce where "reduce s n = (SOME r'::nat\<Rightarrow>nat. strict_mono r' \<and> P n (s o r'))"
    1.13  
    1.14  lemma subseq_reduce[intro, simp]:
    1.15 -  "subseq s \<Longrightarrow> subseq (reduce s n)"
    1.16 +  "strict_mono s \<Longrightarrow> strict_mono (reduce s n)"
    1.17    unfolding reduce_def by (rule someI2_ex[OF ex_subseq]) auto
    1.18  
    1.19  lemma reduce_holds:
    1.20 -  "subseq s \<Longrightarrow> P n (s o reduce s n)"
    1.21 +  "strict_mono s \<Longrightarrow> P n (s o reduce s n)"
    1.22    unfolding reduce_def by (rule someI2_ex[OF ex_subseq]) (auto simp: o_def)
    1.23  
    1.24 -primrec seqseq where
    1.25 +primrec seqseq :: "nat \<Rightarrow> nat \<Rightarrow> nat" where
    1.26    "seqseq 0 = id"
    1.27  | "seqseq (Suc n) = seqseq n o reduce (seqseq n) n"
    1.28  
    1.29 -lemma subseq_seqseq[intro, simp]: "subseq (seqseq n)"
    1.30 +lemma subseq_seqseq[intro, simp]: "strict_mono (seqseq n)"
    1.31  proof (induct n)
    1.32 -  case 0 thus ?case by (simp add: subseq_def)
    1.33 +  case 0 thus ?case by (simp add: strict_mono_def)
    1.34  next
    1.35 -  case (Suc n) thus ?case by (subst seqseq.simps) (auto intro!: subseq_o)
    1.36 +  case (Suc n) thus ?case by (subst seqseq.simps) (auto intro!: strict_mono_o)
    1.37  qed
    1.38  
    1.39  lemma seqseq_holds:
    1.40 @@ -40,35 +40,29 @@
    1.41    thus ?thesis by simp
    1.42  qed
    1.43  
    1.44 -definition diagseq where "diagseq i = seqseq i i"
    1.45 -
    1.46 -lemma subseq_mono: "subseq f \<Longrightarrow> a \<le> b \<Longrightarrow> f a \<le> f b"
    1.47 -  by (metis le_eq_less_or_eq subseq_mono)
    1.48 -
    1.49 -lemma subseq_strict_mono: "subseq f \<Longrightarrow> a < b \<Longrightarrow> f a < f b"
    1.50 -  by (simp add: subseq_def)
    1.51 +definition diagseq :: "nat \<Rightarrow> nat" where "diagseq i = seqseq i i"
    1.52  
    1.53  lemma diagseq_mono: "diagseq n < diagseq (Suc n)"
    1.54  proof -
    1.55    have "diagseq n < seqseq n (Suc n)"
    1.56 -    using subseq_seqseq[of n] by (simp add: diagseq_def subseq_def)
    1.57 +    using subseq_seqseq[of n] by (simp add: diagseq_def strict_mono_def)
    1.58    also have "\<dots> \<le> seqseq n (reduce (seqseq n) n (Suc n))"
    1.59 -    by (auto intro: subseq_mono seq_suble)
    1.60 +    using strict_mono_less_eq seq_suble by blast
    1.61    also have "\<dots> = diagseq (Suc n)" by (simp add: diagseq_def)
    1.62    finally show ?thesis .
    1.63  qed
    1.64  
    1.65 -lemma subseq_diagseq: "subseq diagseq"
    1.66 -  using diagseq_mono by (simp add: subseq_Suc_iff diagseq_def)
    1.67 +lemma subseq_diagseq: "strict_mono diagseq"
    1.68 +  using diagseq_mono by (simp add: strict_mono_Suc_iff diagseq_def)
    1.69  
    1.70  primrec fold_reduce where
    1.71    "fold_reduce n 0 = id"
    1.72  | "fold_reduce n (Suc k) = fold_reduce n k o reduce (seqseq (n + k)) (n + k)"
    1.73  
    1.74 -lemma subseq_fold_reduce[intro, simp]: "subseq (fold_reduce n k)"
    1.75 +lemma subseq_fold_reduce[intro, simp]: "strict_mono (fold_reduce n k)"
    1.76  proof (induct k)
    1.77 -  case (Suc k) from subseq_o[OF this subseq_reduce] show ?case by (simp add: o_def)
    1.78 -qed (simp add: subseq_def)
    1.79 +  case (Suc k) from strict_mono_o[OF this subseq_reduce] show ?case by (simp add: o_def)
    1.80 +qed (simp add: strict_mono_def)
    1.81  
    1.82  lemma ex_subseq_reduce_index: "seqseq (n + k) = seqseq n o fold_reduce n k"
    1.83    by (induct k) simp_all
    1.84 @@ -95,14 +89,14 @@
    1.85    assumes "m \<le> n" shows "diagseq n = (seqseq m o (fold_reduce m (n - m))) n"
    1.86    using diagseq_add[of m "n - m"] assms by simp
    1.87  
    1.88 -lemma subseq_diagonal_rest: "subseq (\<lambda>x. fold_reduce k x (k + x))"
    1.89 -  unfolding subseq_Suc_iff fold_reduce.simps o_def
    1.90 +lemma subseq_diagonal_rest: "strict_mono (\<lambda>x. fold_reduce k x (k + x))"
    1.91 +  unfolding strict_mono_Suc_iff fold_reduce.simps o_def
    1.92  proof
    1.93    fix n
    1.94    have "fold_reduce k n (k + n) < fold_reduce k n (k + Suc n)" (is "?lhs < _")
    1.95 -    by (auto intro: subseq_strict_mono)
    1.96 +    by (auto intro: strict_monoD)
    1.97    also have "\<dots> \<le> fold_reduce k n (reduce (seqseq (k + n)) (k + n) (k + Suc n))"
    1.98 -    by (rule subseq_mono) (auto intro!: seq_suble subseq_mono)
    1.99 +    by (auto intro: less_mono_imp_le_mono seq_suble strict_monoD)
   1.100    finally show "?lhs < \<dots>" .
   1.101  qed
   1.102  
   1.103 @@ -110,7 +104,7 @@
   1.104    by (auto simp: o_def diagseq_add)
   1.105  
   1.106  lemma diagseq_holds:
   1.107 -  assumes subseq_stable: "\<And>r s n. subseq r \<Longrightarrow> P n s \<Longrightarrow> P n (s o r)"
   1.108 +  assumes subseq_stable: "\<And>r s n. strict_mono r \<Longrightarrow> P n s \<Longrightarrow> P n (s o r)"
   1.109    shows "P k (diagseq o (op + (Suc k)))"
   1.110    unfolding diagseq_seqseq by (intro subseq_stable subseq_diagonal_rest seqseq_holds)
   1.111