thys/Exercises.thy
author Christian Urban <urbanc@in.tum.de>
Fri, 30 Jun 2017 21:13:40 +0100
changeset 259 78dd6bca5627
parent 258 thys/Fun.thy@6670f2cb5741
child 260 160d0b08471c
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
     1
theory Exercises
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
  imports Lexer "~~/src/HOL/Library/Infinite_Set"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
section {* some fun tests *}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
fun
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
     8
 zeroable :: "rexp \<Rightarrow> bool"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
where
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    10
  "zeroable (ZERO) \<longleftrightarrow> True"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    11
| "zeroable (ONE) \<longleftrightarrow> False"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    12
| "zeroable (CHAR c) \<longleftrightarrow> False"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    13
| "zeroable (ALT r1 r2) \<longleftrightarrow> zeroable r1 \<and> zeroable r2"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    14
| "zeroable (SEQ r1 r2) \<longleftrightarrow> zeroable r1 \<or> zeroable r2"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    15
| "zeroable (STAR r) \<longleftrightarrow> False"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
lemma zeroable_correctness:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    18
  shows "zeroable r \<longleftrightarrow> L r = {}"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
apply(induct r rule: zeroable.induct)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
apply(auto simp add: Sequ_def)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
fun
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    24
 atmostempty :: "rexp \<Rightarrow> bool"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
where
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    26
  "atmostempty (ZERO) \<longleftrightarrow> True"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    27
| "atmostempty (ONE) \<longleftrightarrow> True"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    28
| "atmostempty (CHAR c) \<longleftrightarrow> False"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    29
| "atmostempty (ALT r1 r2) \<longleftrightarrow> atmostempty r1 \<and> atmostempty r2"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    30
| "atmostempty (SEQ r1 r2) \<longleftrightarrow> 
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    31
     zeroable r1 \<or> zeroable r2 \<or> (atmostempty r1 \<and> atmostempty r2)"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
| "atmostempty (STAR r) = atmostempty r"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
fun
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    35
 somechars :: "rexp \<Rightarrow> bool"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
where
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    37
  "somechars (ZERO) \<longleftrightarrow> False"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    38
| "somechars (ONE) \<longleftrightarrow> False"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    39
| "somechars (CHAR c) \<longleftrightarrow> True"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    40
| "somechars (ALT r1 r2) \<longleftrightarrow> somechars r1 \<or> somechars r2"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    41
| "somechars (SEQ r1 r2) \<longleftrightarrow> 
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    42
      (\<not> zeroable r1 \<and> somechars r2) \<or> (\<not> zeroable r2 \<and> somechars r1) \<or> 
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    43
      (somechars r1 \<and> nullable r2) \<or> (somechars r2 \<and> nullable r1)"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    44
| "somechars (STAR r) \<longleftrightarrow> somechars r"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
lemma somechars_correctness:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    47
  shows "somechars r \<longleftrightarrow> (\<exists>s. s \<noteq> [] \<and> s \<in> L r)"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
apply(induct r rule: somechars.induct)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
prefer 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
apply(rule iffI)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
apply (metis Star_decomp neq_Nil_conv)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
apply(rule iffI)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
apply(simp add: Sequ_def zeroable_correctness nullable_correctness)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
apply(simp add: Sequ_def zeroable_correctness nullable_correctness)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
lemma atmostempty_correctness_aux:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    66
  shows "atmostempty r \<longleftrightarrow> \<not> somechars r"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
apply(induct r)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
apply(auto simp add: zeroable_correctness nullable_correctness somechars_correctness)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
lemma atmostempty_correctness:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    73
  shows "atmostempty r \<longleftrightarrow> L r \<subseteq> {[]}"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
by(auto simp add: atmostempty_correctness_aux somechars_correctness)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
fun
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    77
 infinitestrings :: "rexp \<Rightarrow> bool"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
  "infinitestrings (ZERO) = False"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
| "infinitestrings (ONE) = False"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
| "infinitestrings (CHAR c) = False"
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    82
| "infinitestrings (ALT r1 r2) = (infinitestrings r1 \<or> infinitestrings r2)"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    83
| "infinitestrings (SEQ r1 r2) \<longleftrightarrow> 
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    84
      (\<not> zeroable r1 \<and> infinitestrings r2) \<or> (\<not> zeroable r2 \<and> infinitestrings r1)"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    85
| "infinitestrings (STAR r) = (\<not> atmostempty r)"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
lemma Star_atmostempty:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    88
  assumes "A \<subseteq> {[]}"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    89
  shows "A\<star> \<subseteq> {[]}"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
using assms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
using Star_string concat_eq_Nil_conv empty_iff insert_iff subsetI subset_singletonD by fastforce
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
lemma Star_empty_string_finite:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    94
  shows "finite ({[]}\<star>)"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
using Star_atmostempty infinite_super by auto
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
lemma Star_empty_finite:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
    98
  shows "finite ({}\<star>)"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
using Star_atmostempty infinite_super by auto
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
lemma Star_concat_replicate:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   102
  assumes "s \<in> A"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   103
  shows "concat (replicate n s) \<in> A\<star>"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
using assms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
by (induct n) (auto)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
lemma concat_replicate_inj:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   109
  assumes "concat (replicate n s) = concat (replicate m s)" "s \<noteq> []"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
  shows "n = m"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
using assms
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
apply(induct n arbitrary: m)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
apply(auto)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
apply(case_tac m)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
apply(clarify)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
apply(simp only: replicate.simps concat.simps)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
apply blast
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
by simp
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
lemma A0:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   122
  assumes "finite (A ;; B)" "B \<noteq> {}"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
  shows "finite A"
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   124
apply(subgoal_tac "\<exists>s. s \<in> B")
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
apply(erule exE)
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   126
apply(subgoal_tac "finite {s1 @ s |s1. s1 \<in> A}")
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   127
apply(rule_tac f="\<lambda>s1. s1 @ s" in finite_imageD)
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
apply(simp add: image_def)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
apply(smt Collect_cong)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
apply(simp add: inj_on_def)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
apply(rule_tac B="A ;; B" in finite_subset)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
apply(auto simp add: Sequ_def)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
apply(rule assms(1))
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
using assms(2) by auto
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
lemma A1:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   137
  assumes "finite (A ;; B)" "A \<noteq> {}"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
  shows "finite B"
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   139
apply(subgoal_tac "\<exists>s. s \<in> A")
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
apply(erule exE)
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   141
apply(subgoal_tac "finite {s @ s1 |s1. s1 \<in> B}")
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   142
apply(rule_tac f="\<lambda>s1. s @ s1" in finite_imageD)
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
apply(simp add: image_def)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
apply(smt Collect_cong)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
apply(simp add: inj_on_def)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
apply(rule_tac B="A ;; B" in finite_subset)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
apply(auto simp add: Sequ_def)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
apply(rule assms(1))
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
using assms(2) by auto
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
lemma Sequ_Prod_finite:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   152
  assumes "A \<noteq> {}" "B \<noteq> {}"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   153
  shows "finite (A ;; B) \<longleftrightarrow> (finite (A \<times> B))"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
apply(rule iffI)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
apply(rule finite_cartesian_product)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
apply(erule A0)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
apply(rule assms(2))
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
apply(erule A1)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
apply(rule assms(1))
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
apply(simp add: Sequ_def)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
apply(rule finite_image_set2)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
apply(drule finite_cartesian_productD1)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
apply(rule assms(2))
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
apply(drule finite_cartesian_productD2)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
apply(rule assms(1))
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
lemma Star_non_empty_string_infinite:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   172
  assumes "s \<in> A" " s \<noteq> []"
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   173
  shows "infinite (A\<star>)"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
proof -
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   175
  have "inj (\<lambda>n. concat (replicate n s))" 
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
  using assms(2) concat_replicate_inj
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
    by(auto simp add: inj_on_def)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
  moreover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
  have "infinite (UNIV::nat set)" by simp
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   180
  ultimately
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   181
  have "infinite ((\<lambda>n. concat (replicate n s)) ` UNIV)"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   182
   by (simp add: range_inj_infinite)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   183
  moreover
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   184
  have "((\<lambda>n. concat (replicate n s)) ` UNIV) \<subseteq> (A\<star>)"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
    using Star_concat_replicate assms(1) by auto
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   186
  ultimately show "infinite (A\<star>)" 
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
  using infinite_super by auto
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
qed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   189
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   190
lemma infinitestrings_correctness:
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   191
  shows "infinitestrings r \<longleftrightarrow> infinite (L r)"
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
apply(induct r)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   193
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   194
apply(simp add: zeroable_correctness)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
apply(rule iffI)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
apply(erule disjE)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
apply(subst Sequ_Prod_finite)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
apply(auto)[2]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
using finite_cartesian_productD2 apply blast
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
apply(subst Sequ_Prod_finite)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
apply(auto)[2]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   202
using finite_cartesian_productD1 apply blast
259
78dd6bca5627 updated
Christian Urban <urbanc@in.tum.de>
parents: 258
diff changeset
   203
apply(subgoal_tac "L r1 \<noteq> {} \<and> L r2 \<noteq> {}")
258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   204
prefer 2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   205
apply(auto simp add: Sequ_def)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
apply(subst (asm) Sequ_Prod_finite)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   207
apply(auto)[2]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   208
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   209
apply(simp add: atmostempty_correctness)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   210
apply(rule iffI)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   211
apply (metis Star_empty_finite Star_empty_string_finite subset_singletonD)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   212
using Star_non_empty_string_infinite apply blast
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   213
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   214
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   215
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
end