thys4/posix/GeneralRegexBound.thy
author Chengsong
Wed, 23 Aug 2023 03:02:31 +0100
changeset 668 3831621d7b14
parent 587 3198605ac648
permissions -rw-r--r--
added technical Overview section, almost done introduction
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
     1
theory GeneralRegexBound 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
     2
  imports "BasicIdentities" 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
     3
begin
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
     4
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
     5
lemma size_geq1:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
     6
  shows "rsize r \<ge> 1"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
     7
  by (induct r) auto 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
     8
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
     9
definition RSEQ_set where
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    10
  "RSEQ_set A n \<equiv> {RSEQ r1 r2 | r1 r2. r1 \<in> A \<and> r2 \<in> A \<and> rsize r1 + rsize r2 \<le> n}"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    11
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    12
definition RSEQ_set_cartesian where
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    13
  "RSEQ_set_cartesian A  = {RSEQ r1 r2 | r1 r2. r1 \<in> A \<and> r2 \<in> A}"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    14
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    15
definition RALT_set where
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    16
  "RALT_set A n \<equiv> {RALTS rs | rs. set rs \<subseteq> A \<and> rsizes rs \<le> n}"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    17
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    18
definition RALTs_set where
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    19
  "RALTs_set A n \<equiv> {RALTS rs | rs. \<forall>r \<in> set rs. r \<in> A \<and> rsizes rs \<le> n}"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    20
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    21
definition RNTIMES_set where
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    22
  "RNTIMES_set A n \<equiv> {RNTIMES r m | m r. r \<in> A \<and> rsize r + m \<le> n}"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    23
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    24
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    25
definition
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    26
  "sizeNregex N \<equiv> {r. rsize r \<le> N}"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    27
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    28
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    29
lemma sizenregex_induct1:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    30
  "sizeNregex (Suc n) = (({RZERO, RONE} \<union> {RCHAR c| c. True}) 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    31
                         \<union> (RSTAR ` sizeNregex n) 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    32
                         \<union> (RSEQ_set (sizeNregex n) n)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    33
                         \<union> (RALTs_set (sizeNregex n) n))
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    34
                         \<union> (RNTIMES_set (sizeNregex n) n)"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    35
  apply(auto)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    36
        apply(case_tac x)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    37
             apply(auto simp add: RSEQ_set_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    38
  using sizeNregex_def apply force
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    39
  using sizeNregex_def apply auto[1]
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    40
  apply (simp add: sizeNregex_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    41
         apply (simp add: sizeNregex_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    42
         apply (simp add: RALTs_set_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    43
  apply (metis imageI list.set_map member_le_sum_list order_trans)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    44
  apply (simp add: sizeNregex_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    45
        apply (simp add: sizeNregex_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    46
  apply (simp add: RNTIMES_set_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    47
  apply (simp add: sizeNregex_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    48
  using sizeNregex_def apply force
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    49
  apply (simp add: sizeNregex_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    50
  apply (simp add: sizeNregex_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    51
  apply (simp add: sizeNregex_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    52
    apply (simp add: RALTs_set_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    53
  apply(simp add: sizeNregex_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    54
  apply(auto)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    55
  using ex_in_conv apply fastforce
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    56
  apply (simp add: RNTIMES_set_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    57
  apply(simp add: sizeNregex_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    58
  by force
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    59
  
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    60
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    61
lemma s4:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    62
  "RSEQ_set A n \<subseteq> RSEQ_set_cartesian A"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    63
  using RSEQ_set_cartesian_def RSEQ_set_def by fastforce
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    64
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    65
lemma s5:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    66
  assumes "finite A"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    67
  shows "finite (RSEQ_set_cartesian A)"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    68
  using assms
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    69
  apply(subgoal_tac "RSEQ_set_cartesian A = (\<lambda>(x1, x2). RSEQ x1 x2) ` (A \<times> A)")
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    70
  apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    71
  unfolding RSEQ_set_cartesian_def
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    72
  apply(auto)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    73
  done
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    74
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    75
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    76
definition RALTs_set_length
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    77
  where
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    78
  "RALTs_set_length A n l \<equiv> {RALTS rs | rs. \<forall>r \<in> set rs. r \<in> A \<and> rsizes rs \<le> n \<and> length rs \<le> l}"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    79
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    80
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    81
definition RALTs_set_length2
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    82
  where
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    83
  "RALTs_set_length2 A l \<equiv> {RALTS rs | rs. \<forall>r \<in> set rs. r \<in> A \<and> length rs \<le> l}"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    84
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    85
definition set_length2
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    86
  where
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    87
  "set_length2 A l \<equiv> {rs. \<forall>r \<in> set rs. r \<in> A \<and> length rs \<le> l}"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    88
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    89
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    90
lemma r000: 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    91
  shows "RALTs_set_length A n l \<subseteq> RALTs_set_length2 A l"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    92
  apply(auto simp add: RALTs_set_length2_def RALTs_set_length_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    93
  done
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    94
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    95
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    96
lemma r02: 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    97
  shows "set_length2 A 0 \<subseteq> {[]}"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    98
  apply(auto simp add: set_length2_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
    99
  apply(case_tac x)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   100
  apply(auto)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   101
  done
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   102
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   103
lemma r03:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   104
  shows "set_length2 A (Suc n) \<subseteq> 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   105
          {[]} \<union> (\<lambda>(h, t). h # t) ` (A \<times> (set_length2 A n))"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   106
  apply(auto simp add: set_length2_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   107
  apply(case_tac x)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   108
   apply(auto)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   109
  done
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   110
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   111
lemma r1:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   112
  assumes "finite A" 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   113
  shows "finite (set_length2 A n)"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   114
  using assms
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   115
  apply(induct n)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   116
  apply(rule finite_subset)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   117
    apply(rule r02)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   118
   apply(simp)    
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   119
  apply(rule finite_subset)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   120
   apply(rule r03)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   121
  apply(simp)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   122
  done
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   123
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   124
lemma size_sum_more_than_len:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   125
  shows "rsizes rs \<ge> length rs"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   126
  apply(induct rs)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   127
   apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   128
  apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   129
  apply(subgoal_tac "rsize a \<ge> 1")
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   130
   apply linarith
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   131
  using size_geq1 by auto
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   132
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   133
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   134
lemma sum_list_len:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   135
  shows "rsizes rs \<le> n \<Longrightarrow> length rs \<le> n"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   136
  by (meson order.trans size_sum_more_than_len)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   137
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   138
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   139
lemma t2:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   140
  shows "RALTs_set A n \<subseteq> RALTs_set_length A n n"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   141
  unfolding RALTs_set_length_def RALTs_set_def
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   142
  apply(auto)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   143
  using sum_list_len by blast
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   144
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   145
lemma s8_aux:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   146
  assumes "finite A" 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   147
  shows "finite (RALTs_set_length A n n)"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   148
proof -
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   149
  have "finite A" by fact
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   150
  then have "finite (set_length2 A n)"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   151
    by (simp add: r1)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   152
  moreover have "(RALTS ` (set_length2 A n)) = RALTs_set_length2 A n"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   153
    unfolding RALTs_set_length2_def set_length2_def
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   154
    by (auto)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   155
  ultimately have "finite (RALTs_set_length2 A n)"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   156
    by (metis finite_imageI)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   157
  then show ?thesis
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   158
    by (metis infinite_super r000)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   159
qed
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   160
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   161
lemma char_finite:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   162
  shows "finite  {RCHAR c |c. True}"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   163
  apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   164
  apply(subgoal_tac "finite (RCHAR ` (UNIV::char set))")
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   165
   prefer 2
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   166
   apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   167
  by (simp add: full_SetCompr_eq)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   168
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   169
thm RNTIMES_set_def
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   170
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   171
lemma s9_aux0:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   172
  shows "RNTIMES_set (insert r A) n \<subseteq> RNTIMES_set A n \<union> (\<Union> i \<in> {..n}. {RNTIMES r i})"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   173
apply(auto simp add: RNTIMES_set_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   174
  done
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   175
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   176
lemma s9_aux:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   177
  assumes "finite A"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   178
  shows "finite (RNTIMES_set A n)"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   179
  using assms
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   180
  apply(induct A arbitrary: n)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   181
   apply(auto simp add: RNTIMES_set_def)[1]
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   182
  apply(subgoal_tac "finite (RNTIMES_set F n \<union> (\<Union> i \<in> {..n}. {RNTIMES x i}))")
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   183
  apply (metis finite_subset s9_aux0)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   184
  by blast
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   185
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   186
lemma finite_size_n:
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   187
  shows "finite (sizeNregex n)"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   188
  apply(induct n)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   189
   apply(simp add: sizeNregex_def)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   190
  apply (metis (mono_tags, lifting) not_finite_existsD not_one_le_zero size_geq1)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   191
  apply(subst sizenregex_induct1)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   192
  apply(simp only: finite_Un)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   193
  apply(rule conjI)+
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   194
  apply(simp)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   195
  
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   196
  using char_finite apply blast
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   197
    apply(simp)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   198
   apply(rule finite_subset)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   199
    apply(rule s4)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   200
   apply(rule s5)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   201
   apply(simp)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   202
  apply(rule finite_subset)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   203
   apply(rule t2)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   204
  apply(rule s8_aux)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   205
   apply(simp)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   206
  by (simp add: s9_aux)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   207
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   208
lemma three_easy_cases0: 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   209
  shows "rsize (rders_simp RZERO s) \<le> Suc 0"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   210
  apply(induct s)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   211
   apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   212
  apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   213
  done
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   214
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   215
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   216
lemma three_easy_cases1: 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   217
  shows "rsize (rders_simp RONE s) \<le> Suc 0"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   218
    apply(induct s)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   219
   apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   220
  apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   221
  using three_easy_cases0 by auto
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   222
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   223
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   224
lemma three_easy_casesC: 
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   225
  shows "rsize (rders_simp (RCHAR c) s) \<le> Suc 0"
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   226
  apply(induct s)
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   227
   apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   228
  apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   229
  apply(case_tac " a = c")
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   230
  using three_easy_cases1 apply blast
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   231
  apply simp
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   232
  using three_easy_cases0 by force
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   233
  
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   234
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   235
unused_thms
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   236
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   237
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   238
end
3198605ac648 bsimp idempotency
Chengsong
parents:
diff changeset
   239