thys2/SpecExt.thy
author Chengsong
Fri, 24 Jun 2022 21:49:23 +0100
changeset 553 0f00d440f484
parent 365 ec5e4fe4cc70
permissions -rw-r--r--
more changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     1
   
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     2
theory SpecExt
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     3
  imports Main (*"~~/src/HOL/Library/Sublist"*)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     4
begin
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     5
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     6
section {* Sequential Composition of Languages *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     7
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     8
definition
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     9
  Sequ :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ;; _" [100,100] 100)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    10
where 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    11
  "A ;; B = {s1 @ s2 | s1 s2. s1 \<in> A \<and> s2 \<in> B}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    12
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    13
text {* Two Simple Properties about Sequential Composition *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    14
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    15
lemma Sequ_empty_string [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    16
  shows "A ;; {[]} = A"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    17
  and   "{[]} ;; A = A"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    18
by (simp_all add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    19
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    20
lemma Sequ_empty [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    21
  shows "A ;; {} = {}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    22
  and   "{} ;; A = {}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    23
by (simp_all add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    24
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    25
lemma Sequ_assoc:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    26
  shows "(A ;; B) ;; C = A ;; (B ;; C)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    27
apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    28
apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    29
by (metis append_assoc)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    30
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    31
lemma Sequ_Union_in:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    32
  shows "(A ;; (\<Union>x\<in> B. C x)) = (\<Union>x\<in> B. A ;; C x)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    33
by (auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    34
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    35
section {* Semantic Derivative (Left Quotient) of Languages *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    36
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    37
definition
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    38
  Der :: "char \<Rightarrow> string set \<Rightarrow> string set"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    39
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    40
  "Der c A \<equiv> {s. c # s \<in> A}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    41
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    42
definition
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    43
  Ders :: "string \<Rightarrow> string set \<Rightarrow> string set"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    44
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    45
  "Ders s A \<equiv> {s'. s @ s' \<in> A}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    46
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    47
lemma Der_null [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    48
  shows "Der c {} = {}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    49
unfolding Der_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    50
by auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    51
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    52
lemma Der_empty [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    53
  shows "Der c {[]} = {}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    54
unfolding Der_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    55
by auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    56
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    57
lemma Der_char [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    58
  shows "Der c {[d]} = (if c = d then {[]} else {})"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    59
unfolding Der_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    60
by auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    61
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    62
lemma Der_union [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    63
  shows "Der c (A \<union> B) = Der c A \<union> Der c B"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    64
unfolding Der_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    65
by auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    66
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    67
lemma Der_UNION [simp]: 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    68
  shows "Der c (\<Union>x\<in>A. B x) = (\<Union>x\<in>A. Der c (B x))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    69
by (auto simp add: Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    70
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    71
lemma Der_Sequ [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    72
  shows "Der c (A ;; B) = (Der c A) ;; B \<union> (if [] \<in> A then Der c B else {})"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    73
unfolding Der_def Sequ_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    74
  by (auto simp add: Cons_eq_append_conv)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    75
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    76
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    77
section {* Kleene Star for Languages *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    78
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    79
inductive_set
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    80
  Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    81
  for A :: "string set"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    82
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    83
  start[intro]: "[] \<in> A\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    84
| step[intro]:  "\<lbrakk>s1 \<in> A; s2 \<in> A\<star>\<rbrakk> \<Longrightarrow> s1 @ s2 \<in> A\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    85
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    86
(* Arden's lemma *)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    87
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    88
lemma Star_cases:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    89
  shows "A\<star> = {[]} \<union> A ;; A\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    90
unfolding Sequ_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    91
by (auto) (metis Star.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    92
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    93
lemma Star_decomp: 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    94
  assumes "c # x \<in> A\<star>" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    95
  shows "\<exists>s1 s2. x = s1 @ s2 \<and> c # s1 \<in> A \<and> s2 \<in> A\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    96
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    97
by (induct x\<equiv>"c # x" rule: Star.induct) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    98
   (auto simp add: append_eq_Cons_conv)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    99
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   100
lemma Star_Der_Sequ: 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   101
  shows "Der c (A\<star>) \<subseteq> (Der c A) ;; A\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   102
unfolding Der_def Sequ_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   103
by(auto simp add: Star_decomp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   104
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   105
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   106
lemma Der_star [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   107
  shows "Der c (A\<star>) = (Der c A) ;; A\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   108
proof -    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   109
  have "Der c (A\<star>) = Der c ({[]} \<union> A ;; A\<star>)"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   110
    by (simp only: Star_cases[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   111
  also have "... = Der c (A ;; A\<star>)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   112
    by (simp only: Der_union Der_empty) (simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   113
  also have "... = (Der c A) ;; A\<star> \<union> (if [] \<in> A then Der c (A\<star>) else {})"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   114
    by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   115
  also have "... =  (Der c A) ;; A\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   116
    using Star_Der_Sequ by auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   117
  finally show "Der c (A\<star>) = (Der c A) ;; A\<star>" .
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   118
qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   119
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   120
section {* Power operation for Sets *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   121
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   122
fun 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   123
  Pow :: "string set \<Rightarrow> nat \<Rightarrow> string set" ("_ \<up> _" [101, 102] 101)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   124
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   125
   "A \<up> 0 = {[]}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   126
|  "A \<up> (Suc n) = A ;; (A \<up> n)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   127
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   128
lemma Pow_empty [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   129
  shows "[] \<in> A \<up> n \<longleftrightarrow> (n = 0 \<or> [] \<in> A)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   130
by(induct n) (auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   131
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   132
lemma Pow_Suc_rev:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   133
  "A \<up> (Suc n) =  (A \<up> n) ;; A"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   134
apply(induct n arbitrary: A)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   135
apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   136
by (metis Sequ_assoc)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   137
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   138
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   139
lemma Pow_decomp: 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   140
  assumes "c # x \<in> A \<up> n" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   141
  shows "\<exists>s1 s2. x = s1 @ s2 \<and> c # s1 \<in> A \<and> s2 \<in> A \<up> (n - 1)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   142
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   143
apply(induct n) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   144
apply(auto simp add: Cons_eq_append_conv Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   145
apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   146
apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   147
apply(blast)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   148
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   149
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   150
lemma Star_Pow:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   151
  assumes "s \<in> A\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   152
  shows "\<exists>n. s \<in> A \<up> n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   153
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   154
apply(induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   155
apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   156
apply(rule_tac x="Suc n" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   157
apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   158
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   159
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   160
lemma Pow_Star:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   161
  assumes "s \<in> A \<up> n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   162
  shows "s \<in> A\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   163
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   164
apply(induct n arbitrary: s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   165
apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   166
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   167
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   168
lemma
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   169
  assumes "[] \<in> A" "n \<noteq> 0" "A \<noteq> {}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   170
  shows "A \<up> (Suc n) = A \<up> n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   171
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   172
lemma Der_Pow_0:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   173
  shows "Der c (A \<up> 0) = {}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   174
by(simp add: Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   175
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   176
lemma Der_Pow_Suc:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   177
  shows "Der c (A \<up> (Suc n)) = (Der c A) ;; (A \<up> n)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   178
unfolding Der_def Sequ_def 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   179
apply(auto simp add: Cons_eq_append_conv Sequ_def dest!: Pow_decomp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   180
apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   181
apply(force simp add: Sequ_def)+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   182
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   183
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   184
lemma Der_Pow [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   185
  shows "Der c (A \<up> n) = (if n = 0 then {} else (Der c A) ;; (A \<up> (n - 1)))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   186
apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   187
apply(simp_all del: Pow.simps add: Der_Pow_0 Der_Pow_Suc)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   188
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   189
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   190
lemma Der_Pow_Sequ [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   191
  shows "Der c (A ;; A \<up> n) = (Der c A) ;; (A \<up> n)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   192
by (simp only: Pow.simps[symmetric] Der_Pow) (simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   193
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   194
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   195
lemma Pow_Sequ_Un:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   196
  assumes "0 < x"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   197
  shows "(\<Union>n \<in> {..x}. (A \<up> n)) = ({[]} \<union> (\<Union>n \<in> {..x - Suc 0}. A ;; (A \<up> n)))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   198
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   199
apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   200
apply(smt Pow.elims Sequ_def Suc_le_mono Suc_pred atMost_iff empty_iff insert_iff mem_Collect_eq)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   201
apply(rule_tac x="Suc xa" in bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   202
apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   203
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   204
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   205
lemma Pow_Sequ_Un2:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   206
  assumes "0 < x"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   207
  shows "(\<Union>n \<in> {x..}. (A \<up> n)) = (\<Union>n \<in> {x - Suc 0..}. A ;; (A \<up> n))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   208
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   209
apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   210
apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   211
apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   212
apply fastforce
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   213
apply(case_tac x)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   214
apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   215
apply(rule_tac x="Suc xa" in bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   216
apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   217
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   218
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   219
section {* Regular Expressions *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   220
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   221
datatype rexp =
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   222
  ZERO
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   223
| ONE
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   224
| CHAR char
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   225
| SEQ rexp rexp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   226
| ALT rexp rexp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   227
| STAR rexp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   228
| UPNTIMES rexp nat
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   229
| NTIMES rexp nat
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   230
| FROMNTIMES rexp nat
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   231
| NMTIMES rexp nat nat
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   232
| NOT rexp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   233
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   234
section {* Semantics of Regular Expressions *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   235
 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   236
fun
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   237
  L :: "rexp \<Rightarrow> string set"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   238
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   239
  "L (ZERO) = {}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   240
| "L (ONE) = {[]}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   241
| "L (CHAR c) = {[c]}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   242
| "L (SEQ r1 r2) = (L r1) ;; (L r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   243
| "L (ALT r1 r2) = (L r1) \<union> (L r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   244
| "L (STAR r) = (L r)\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   245
| "L (UPNTIMES r n) = (\<Union>i\<in>{..n} . (L r) \<up> i)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   246
| "L (NTIMES r n) = (L r) \<up> n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   247
| "L (FROMNTIMES r n) = (\<Union>i\<in>{n..} . (L r) \<up> i)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   248
| "L (NMTIMES r n m) = (\<Union>i\<in>{n..m} . (L r) \<up> i)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   249
| "L (NOT r) = ((UNIV:: string set)  - L r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   250
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   251
section {* Nullable, Derivatives *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   252
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   253
fun
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   254
 nullable :: "rexp \<Rightarrow> bool"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   255
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   256
  "nullable (ZERO) = False"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   257
| "nullable (ONE) = True"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   258
| "nullable (CHAR c) = False"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   259
| "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   260
| "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   261
| "nullable (STAR r) = True"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   262
| "nullable (UPNTIMES r n) = True"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   263
| "nullable (NTIMES r n) = (if n = 0 then True else nullable r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   264
| "nullable (FROMNTIMES r n) = (if n = 0 then True else nullable r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   265
| "nullable (NMTIMES r n m) = (if m < n then False else (if n = 0 then True else nullable r))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   266
| "nullable (NOT r) = (\<not> nullable r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   267
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   268
fun
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   269
 der :: "char \<Rightarrow> rexp \<Rightarrow> rexp"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   270
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   271
  "der c (ZERO) = ZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   272
| "der c (ONE) = ZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   273
| "der c (CHAR d) = (if c = d then ONE else ZERO)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   274
| "der c (ALT r1 r2) = ALT (der c r1) (der c r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   275
| "der c (SEQ r1 r2) = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   276
     (if nullable r1
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   277
      then ALT (SEQ (der c r1) r2) (der c r2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   278
      else SEQ (der c r1) r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   279
| "der c (STAR r) = SEQ (der c r) (STAR r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   280
| "der c (UPNTIMES r n) = (if n = 0 then ZERO else SEQ (der c r) (UPNTIMES r (n - 1)))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   281
| "der c (NTIMES r n) = (if n = 0 then ZERO else SEQ (der c r) (NTIMES r (n - 1)))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   282
| "der c (FROMNTIMES r n) =
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   283
     (if n = 0 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   284
      then SEQ (der c r) (STAR r)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   285
      else SEQ (der c r) (FROMNTIMES r (n - 1)))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   286
| "der c (NMTIMES r n m) = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   287
     (if m < n then ZERO 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   288
      else (if n = 0 then (if m = 0 then ZERO else 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   289
                           SEQ (der c r) (UPNTIMES r (m - 1))) else 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   290
                           SEQ (der c r) (NMTIMES r (n - 1) (m - 1))))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   291
| "der c (NOT r) = NOT (der c r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   292
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   293
lemma
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   294
 "L(der c (UPNTIMES r m))  =
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   295
     L(if (m = 0) then ZERO else ALT ONE (SEQ(der c r) (UPNTIMES r (m - 1))))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   296
  apply(case_tac m)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   297
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   298
  apply(simp del: der.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   299
  apply(simp only: der.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   300
  apply(simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   301
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   302
  defer
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   303
  apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   304
  oops
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   305
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   306
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   307
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   308
lemma 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   309
  assumes "der c r = ONE \<or> der c r = ZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   310
  shows "L (der c (NOT r)) \<noteq> L(if (der c r = ZERO) then ONE else 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   311
                               if (der c r = ONE) then ZERO
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   312
                               else NOT(der c r))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   313
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   314
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   315
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   316
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   317
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   318
lemma 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   319
  "L (der c (NOT r)) = L(if (der c r = ZERO) then ONE else 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   320
                         if (der c r = ONE) then ZERO
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   321
                         else NOT(der c r))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   322
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   323
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   324
  oops
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   325
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   326
lemma pow_add:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   327
  assumes "s1 \<in> A \<up> n" "s2 \<in> A \<up> m"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   328
  shows "s1 @ s2 \<in> A \<up> (n + m)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   329
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   330
  apply(induct n arbitrary: m s1 s2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   331
  apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   332
  by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   333
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   334
lemma pow_add2:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   335
  assumes "x \<in> A \<up> (m + n)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   336
  shows "x \<in> A \<up> m ;; A \<up> n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   337
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   338
  apply(induct m arbitrary: n x)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   339
  apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   340
  by (metis append.assoc)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   341
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   342
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   343
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   344
lemma
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   345
 "L(FROMNTIMES r n) = L(SEQ (NTIMES r n) (STAR r))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   346
  apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   347
  defer
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   348
   apply(subgoal_tac "\<exists>m. s2 \<in> (L r) \<up> m")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   349
  prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   350
    apply (simp add: Star_Pow)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   351
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   352
  apply(rule_tac x="n + m" in bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   353
    apply (simp add: pow_add)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   354
   apply simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   355
  apply(subgoal_tac "\<exists>m. m + n = xa")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   356
   apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   357
   prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   358
  using le_add_diff_inverse2 apply auto[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   359
  by (smt Pow_Star Sequ_def add.commute mem_Collect_eq pow_add2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   360
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   361
lemma
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   362
   "L (der c (FROMNTIMES r n)) = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   363
     L (SEQ (der c r) (FROMNTIMES r (n - 1)))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   364
  apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   365
  using Star_Pow apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   366
  using Pow_Star by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   367
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   368
lemma
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   369
 "L (der c (UPNTIMES r n)) = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   370
    L(if n = 0 then ZERO  else 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   371
      ALT (der c r) (SEQ (der c r) (UPNTIMES r (n - 1))))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   372
  apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   373
  using SpecExt.Pow_empty by blast 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   374
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   375
abbreviation "FROM \<equiv> FROMNTIMES"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   376
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   377
lemma
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   378
  shows "L (der c (FROM r n)) = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   379
         L (if n <= 0 then SEQ (der c r) (ALT ONE (FROM r 0))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   380
                      else SEQ (der c r) (ALT ZERO (FROM r (n -1))))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   381
  apply(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   382
  oops
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   383
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   384
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   385
fun 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   386
 ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   387
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   388
  "ders [] r = r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   389
| "ders (c # s) r = ders s (der c r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   390
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   391
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   392
lemma nullable_correctness:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   393
  shows "nullable r  \<longleftrightarrow> [] \<in> (L r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   394
by(induct r) (auto simp add: Sequ_def) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   395
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   396
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   397
lemma der_correctness:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   398
  shows "L (der c r) = Der c (L r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   399
apply(induct r) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   400
apply(simp add: nullable_correctness del: Der_UNION)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   401
apply(simp add: nullable_correctness del: Der_UNION)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   402
apply(simp add: nullable_correctness del: Der_UNION)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   403
apply(simp add: nullable_correctness del: Der_UNION)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   404
apply(simp add: nullable_correctness del: Der_UNION)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   405
apply(simp add: nullable_correctness del: Der_UNION)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   406
      prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   407
      apply(simp only: der.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   408
      apply(case_tac "x2 = 0")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   409
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   410
      apply(simp del: Der_Sequ L.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   411
      apply(subst L.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   412
  apply(subst (2) L.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   413
  thm Der_UNION
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   414
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   415
apply(simp add: nullable_correctness del: Der_UNION)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   416
apply(simp add: nullable_correctness del: Der_UNION)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   417
apply(rule impI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   418
apply(subst Sequ_Union_in)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   419
apply(subst Der_Pow_Sequ[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   420
apply(subst Pow.simps[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   421
apply(subst Der_UNION[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   422
apply(subst Pow_Sequ_Un)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   423
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   424
apply(simp only: Der_union Der_empty)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   425
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   426
(* FROMNTIMES *)    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   427
   apply(simp add: nullable_correctness del: Der_UNION)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   428
  apply(rule conjI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   429
prefer 2    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   430
apply(subst Sequ_Union_in)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   431
apply(subst Der_Pow_Sequ[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   432
apply(subst Pow.simps[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   433
apply(case_tac x2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   434
prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   435
apply(subst Pow_Sequ_Un2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   436
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   437
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   438
    apply(auto simp add: Sequ_def Der_def)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   439
   apply(auto simp add: Sequ_def split: if_splits)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   440
  using Star_Pow apply fastforce
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   441
  using Pow_Star apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   442
(* NMTIMES *)    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   443
apply(simp add: nullable_correctness del: Der_UNION)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   444
apply(rule impI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   445
apply(rule conjI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   446
apply(rule impI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   447
apply(subst Sequ_Union_in)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   448
apply(subst Der_Pow_Sequ[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   449
apply(subst Pow.simps[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   450
apply(subst Der_UNION[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   451
apply(case_tac x3a)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   452
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   453
apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   454
apply(auto simp add: Sequ_def Der_def Cons_eq_append_conv)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   455
apply(rule_tac x="Suc xa" in bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   456
apply(auto simp add: Sequ_def)[2]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   457
apply (metis append_Cons)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   458
apply (metis (no_types, hide_lams) Pow_decomp atMost_iff diff_Suc_eq_diff_pred diff_is_0_eq)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   459
apply(rule impI)+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   460
apply(subst Sequ_Union_in)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   461
apply(subst Der_Pow_Sequ[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   462
apply(subst Pow.simps[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   463
apply(subst Der_UNION[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   464
apply(case_tac x2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   465
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   466
apply(simp del: Pow.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   467
apply(auto simp add: Sequ_def Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   468
apply (metis One_nat_def Suc_le_D Suc_le_mono atLeastAtMost_iff diff_Suc_1 not_le)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   469
by fastforce
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   470
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   471
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   472
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   473
lemma ders_correctness:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   474
  shows "L (ders s r) = Ders s (L r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   475
by (induct s arbitrary: r)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   476
   (simp_all add: Ders_def der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   477
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   478
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   479
section {* Values *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   480
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   481
datatype val = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   482
  Void
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   483
| Char char
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   484
| Seq val val
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   485
| Right val
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   486
| Left val
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   487
| Stars "val list"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   488
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   489
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   490
section {* The string behind a value *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   491
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   492
fun 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   493
  flat :: "val \<Rightarrow> string"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   494
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   495
  "flat (Void) = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   496
| "flat (Char c) = [c]"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   497
| "flat (Left v) = flat v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   498
| "flat (Right v) = flat v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   499
| "flat (Seq v1 v2) = (flat v1) @ (flat v2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   500
| "flat (Stars []) = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   501
| "flat (Stars (v#vs)) = (flat v) @ (flat (Stars vs))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   502
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   503
abbreviation
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   504
  "flats vs \<equiv> concat (map flat vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   505
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   506
lemma flat_Stars [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   507
 "flat (Stars vs) = flats vs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   508
by (induct vs) (auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   509
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   510
lemma Star_concat:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   511
  assumes "\<forall>s \<in> set ss. s \<in> A"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   512
  shows "concat ss \<in> A\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   513
using assms by (induct ss) (auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   514
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   515
lemma Star_cstring:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   516
  assumes "s \<in> A\<star>"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   517
  shows "\<exists>ss. concat ss = s \<and> (\<forall>s \<in> set ss. s \<in> A \<and> s \<noteq> [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   518
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   519
apply(induct rule: Star.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   520
apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   521
apply(rule_tac x="[]" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   522
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   523
apply(erule exE)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   524
apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   525
apply(case_tac "s1 = []")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   526
apply(rule_tac x="ss" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   527
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   528
apply(rule_tac x="s1#ss" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   529
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   530
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   531
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   532
lemma Aux:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   533
  assumes "\<forall>s\<in>set ss. s = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   534
  shows "concat ss = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   535
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   536
by (induct ss) (auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   537
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   538
lemma Pow_cstring_nonempty:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   539
  assumes "s \<in> A \<up> n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   540
  shows "\<exists>ss. concat ss = s \<and> length ss \<le> n \<and> (\<forall>s \<in> set ss. s \<in> A \<and> s \<noteq> [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   541
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   542
apply(induct n arbitrary: s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   543
apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   544
apply(simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   545
apply(erule exE)+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   546
apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   547
apply(drule_tac x="s2" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   548
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   549
apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   550
apply(case_tac "s1 = []")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   551
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   552
apply(rule_tac x="ss" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   553
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   554
apply(rule_tac x="s1 # ss" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   555
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   556
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   557
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   558
lemma Pow_cstring:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   559
  assumes "s \<in> A \<up> n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   560
  shows "\<exists>ss1 ss2. concat (ss1 @ ss2) = s \<and> length (ss1 @ ss2) = n \<and> 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   561
         (\<forall>s \<in> set ss1. s \<in> A \<and> s \<noteq> []) \<and> (\<forall>s \<in> set ss2. s \<in> A \<and> s = [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   562
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   563
apply(induct n arbitrary: s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   564
apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   565
apply(simp only: Pow_Suc_rev)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   566
apply(simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   567
apply(erule exE)+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   568
apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   569
apply(drule_tac x="s1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   570
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   571
apply(erule exE)+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   572
apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   573
apply(case_tac "s2 = []")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   574
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   575
apply(rule_tac x="ss1" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   576
apply(rule_tac x="s2#ss2" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   577
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   578
apply(rule_tac x="ss1 @ [s2]" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   579
apply(rule_tac x="ss2" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   580
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   581
apply(subst Aux)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   582
apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   583
apply(subst Aux)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   584
apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   585
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   586
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   587
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   588
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   589
section {* Lexical Values *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   590
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   591
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   592
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   593
inductive 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   594
  Prf :: "val \<Rightarrow> rexp \<Rightarrow> bool" ("\<Turnstile> _ : _" [100, 100] 100)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   595
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   596
 "\<lbrakk>\<Turnstile> v1 : r1; \<Turnstile> v2 : r2\<rbrakk> \<Longrightarrow> \<Turnstile>  Seq v1 v2 : SEQ r1 r2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   597
| "\<Turnstile> v1 : r1 \<Longrightarrow> \<Turnstile> Left v1 : ALT r1 r2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   598
| "\<Turnstile> v2 : r2 \<Longrightarrow> \<Turnstile> Right v2 : ALT r1 r2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   599
| "\<Turnstile> Void : ONE"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   600
| "\<Turnstile> Char c : CHAR c"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   601
| "\<lbrakk>\<forall>v \<in> set vs. \<Turnstile> v : r \<and> flat v \<noteq> []\<rbrakk> \<Longrightarrow> \<Turnstile> Stars vs : STAR r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   602
| "\<lbrakk>\<forall>v \<in> set vs. \<Turnstile> v : r \<and> flat v \<noteq> []; length vs \<le> n\<rbrakk> \<Longrightarrow> \<Turnstile> Stars vs : UPNTIMES r n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   603
| "\<lbrakk>\<forall>v \<in> set vs1. \<Turnstile> v : r \<and> flat v \<noteq> []; 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   604
    \<forall>v \<in> set vs2. \<Turnstile> v : r \<and> flat v = []; 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   605
    length (vs1 @ vs2) = n\<rbrakk> \<Longrightarrow> \<Turnstile> Stars (vs1 @ vs2) : NTIMES r n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   606
| "\<lbrakk>\<forall>v \<in> set vs1. \<Turnstile> v : r  \<and> flat v \<noteq> []; 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   607
    \<forall>v \<in> set vs2. \<Turnstile> v : r \<and> flat v = []; 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   608
    length (vs1 @ vs2) = n\<rbrakk> \<Longrightarrow> \<Turnstile> Stars (vs1 @ vs2) : FROMNTIMES r n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   609
| "\<lbrakk>\<forall>v \<in> set vs. \<Turnstile> v : r  \<and> flat v \<noteq> []; length vs > n\<rbrakk> \<Longrightarrow> \<Turnstile> Stars vs : FROMNTIMES r n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   610
| "\<lbrakk>\<forall>v \<in> set vs1. \<Turnstile> v : r \<and> flat v \<noteq> [];
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   611
    \<forall>v \<in> set vs2. \<Turnstile> v : r \<and> flat v = []; 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   612
    length (vs1 @ vs2) = n; length (vs1 @ vs2) \<le> m\<rbrakk> \<Longrightarrow> \<Turnstile> Stars (vs1 @ vs2) : NMTIMES r n m"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   613
| "\<lbrakk>\<forall>v \<in> set vs. \<Turnstile> v : r \<and> flat v \<noteq> [];
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   614
    length vs > n; length vs \<le> m\<rbrakk> \<Longrightarrow> \<Turnstile> Stars vs : NMTIMES r n m"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   615
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   616
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   617
 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   618
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   619
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   620
inductive_cases Prf_elims:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   621
  "\<Turnstile> v : ZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   622
  "\<Turnstile> v : SEQ r1 r2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   623
  "\<Turnstile> v : ALT r1 r2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   624
  "\<Turnstile> v : ONE"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   625
  "\<Turnstile> v : CHAR c"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   626
  "\<Turnstile> vs : STAR r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   627
  "\<Turnstile> vs : UPNTIMES r n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   628
  "\<Turnstile> vs : NTIMES r n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   629
  "\<Turnstile> vs : FROMNTIMES r n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   630
  "\<Turnstile> vs : NMTIMES r n m"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   631
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   632
lemma Prf_Stars_appendE:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   633
  assumes "\<Turnstile> Stars (vs1 @ vs2) : STAR r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   634
  shows "\<Turnstile> Stars vs1 : STAR r \<and> \<Turnstile> Stars vs2 : STAR r" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   635
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   636
by (auto intro: Prf.intros elim!: Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   637
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   638
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   639
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   640
lemma flats_empty:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   641
  assumes "(\<forall>v\<in>set vs. flat v = [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   642
  shows "flats vs = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   643
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   644
by(induct vs) (simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   645
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   646
lemma Star_cval:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   647
  assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<Turnstile> v : r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   648
  shows "\<exists>vs. flats vs = concat ss \<and> (\<forall>v\<in>set vs. \<Turnstile> v : r \<and> flat v \<noteq> [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   649
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   650
apply(induct ss)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   651
apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   652
apply(rule_tac x="[]" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   653
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   654
apply(case_tac "flat v = []")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   655
apply(rule_tac x="vs" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   656
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   657
apply(rule_tac x="v#vs" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   658
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   659
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   660
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   661
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   662
lemma flats_cval:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   663
  assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<Turnstile> v : r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   664
  shows "\<exists>vs1 vs2. flats (vs1 @ vs2) = concat ss \<and> length (vs1 @ vs2) = length ss \<and> 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   665
          (\<forall>v\<in>set vs1. \<Turnstile> v : r \<and> flat v \<noteq> []) \<and>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   666
          (\<forall>v\<in>set vs2. \<Turnstile> v : r \<and> flat v = [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   667
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   668
apply(induct ss rule: rev_induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   669
apply(rule_tac x="[]" in exI)+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   670
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   671
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   672
apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   673
apply(case_tac "flat v = []")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   674
apply(rule_tac x="vs1" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   675
apply(rule_tac x="v#vs2" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   676
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   677
apply(rule_tac x="vs1 @ [v]" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   678
apply(rule_tac x="vs2" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   679
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   680
apply(subst (asm) (2) flats_empty)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   681
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   682
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   683
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   684
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   685
lemma flats_cval_nonempty:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   686
  assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<Turnstile> v : r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   687
  shows "\<exists>vs. flats vs = concat ss \<and> length vs \<le> length ss \<and> 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   688
          (\<forall>v\<in>set vs. \<Turnstile> v : r \<and> flat v \<noteq> [])" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   689
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   690
apply(induct ss)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   691
apply(rule_tac x="[]" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   692
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   693
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   694
apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   695
apply(case_tac "flat v = []")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   696
apply(rule_tac x="vs" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   697
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   698
apply(rule_tac x="v # vs" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   699
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   700
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   701
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   702
lemma Pow_flats:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   703
  assumes "\<forall>v \<in> set vs. flat v \<in> A"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   704
  shows "flats vs \<in> A \<up> length vs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   705
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   706
by(induct vs)(auto simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   707
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   708
lemma Pow_flats_appends:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   709
  assumes "\<forall>v \<in> set vs1. flat v \<in> A" "\<forall>v \<in> set vs2. flat v \<in> A"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   710
  shows "flats vs1 @ flats vs2 \<in> A \<up> (length vs1 + length vs2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   711
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   712
apply(induct vs1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   713
apply(auto simp add: Sequ_def Pow_flats)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   714
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   715
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   716
lemma L_flat_Prf1:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   717
  assumes "\<Turnstile> v : r" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   718
  shows "flat v \<in> L r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   719
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   720
apply(induct) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   721
apply(auto simp add: Sequ_def Star_concat Pow_flats)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   722
apply(meson Pow_flats atMost_iff)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   723
using Pow_flats_appends apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   724
using Pow_flats_appends apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   725
apply (meson Pow_flats atLeast_iff less_imp_le)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   726
apply(rule_tac x="length vs1 + length vs2" in  bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   727
apply(meson Pow_flats_appends atLeastAtMost_iff)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   728
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   729
apply(meson Pow_flats atLeastAtMost_iff less_or_eq_imp_le)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   730
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   731
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   732
lemma L_flat_Prf2:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   733
  assumes "s \<in> L r" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   734
  shows "\<exists>v. \<Turnstile> v : r \<and> flat v = s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   735
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   736
proof(induct r arbitrary: s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   737
  case (STAR r s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   738
  have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<Turnstile> v : r \<and> flat v = s" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   739
  have "s \<in> L (STAR r)" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   740
  then obtain ss where "concat ss = s" "\<forall>s \<in> set ss. s \<in> L r \<and> s \<noteq> []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   741
  using Star_cstring by auto  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   742
  then obtain vs where "flats vs = s" "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> flat v \<noteq> []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   743
  using IH Star_cval by metis 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   744
  then show "\<exists>v. \<Turnstile> v : STAR r \<and> flat v = s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   745
  using Prf.intros(6) flat_Stars by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   746
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   747
  case (SEQ r1 r2 s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   748
  then show "\<exists>v. \<Turnstile> v : SEQ r1 r2 \<and> flat v = s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   749
  unfolding Sequ_def L.simps by (fastforce intro: Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   750
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   751
  case (ALT r1 r2 s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   752
  then show "\<exists>v. \<Turnstile> v : ALT r1 r2 \<and> flat v = s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   753
  unfolding L.simps by (fastforce intro: Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   754
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   755
  case (NTIMES r n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   756
  have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<Turnstile> v : r \<and> flat v = s" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   757
  have "s \<in> L (NTIMES r n)" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   758
  then obtain ss1 ss2 where "concat (ss1 @ ss2) = s" "length (ss1 @ ss2) = n" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   759
    "\<forall>s \<in> set ss1. s \<in> L r \<and> s \<noteq> []" "\<forall>s \<in> set ss2. s \<in> L r \<and> s = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   760
  using Pow_cstring by force
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   761
  then obtain vs1 vs2 where "flats (vs1 @ vs2) = s" "length (vs1 @ vs2) = n" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   762
      "\<forall>v\<in>set vs1. \<Turnstile> v : r \<and> flat v \<noteq> []" "\<forall>v\<in>set vs2. \<Turnstile> v : r \<and> flat v = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   763
  using IH flats_cval 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   764
  apply -
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   765
  apply(drule_tac x="ss1 @ ss2" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   766
  apply(drule_tac x="r" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   767
  apply(drule meta_mp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   768
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   769
  apply (metis Un_iff)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   770
  apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   771
  apply(drule_tac x="vs1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   772
  apply(drule_tac x="vs2" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   773
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   774
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   775
  then show "\<exists>v. \<Turnstile> v : NTIMES r n \<and> flat v = s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   776
  using Prf.intros(8) flat_Stars by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   777
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   778
  case (FROMNTIMES r n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   779
  have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<Turnstile> v : r \<and> flat v = s" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   780
  have "s \<in> L (FROMNTIMES r n)" by fact 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   781
  then obtain ss1 ss2 k where "concat (ss1 @ ss2) = s" "length (ss1 @ ss2) = k"  "n \<le> k"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   782
    "\<forall>s \<in> set ss1. s \<in> L r \<and> s \<noteq> []" "\<forall>s \<in> set ss2. s \<in> L r \<and> s = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   783
    using Pow_cstring by force 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   784
  then obtain vs1 vs2 where "flats (vs1 @ vs2) = s" "length (vs1 @ vs2) = k" "n \<le> k"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   785
      "\<forall>v\<in>set vs1. \<Turnstile> v : r \<and> flat v \<noteq> []" "\<forall>v\<in>set vs2. \<Turnstile> v : r \<and> flat v = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   786
  using IH flats_cval 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   787
  apply -
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   788
  apply(drule_tac x="ss1 @ ss2" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   789
  apply(drule_tac x="r" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   790
  apply(drule meta_mp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   791
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   792
  apply (metis Un_iff)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   793
  apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   794
  apply(drule_tac x="vs1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   795
  apply(drule_tac x="vs2" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   796
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   797
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   798
  then show "\<exists>v. \<Turnstile> v : FROMNTIMES r n \<and> flat v = s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   799
  apply(case_tac "length vs1 \<le> n")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   800
  apply(rule_tac x="Stars (vs1 @ take (n - length vs1) vs2)" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   801
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   802
  apply(subgoal_tac "flats (take (n - length vs1) vs2) = []")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   803
  prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   804
  apply (meson flats_empty in_set_takeD)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   805
  apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   806
    apply(rule conjI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   807
      apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   808
        apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   809
       apply (meson in_set_takeD)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   810
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   811
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   812
     apply (simp add: flats_empty)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   813
      apply(rule_tac x="Stars vs1" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   814
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   815
    apply(rule conjI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   816
     apply(rule Prf.intros(10))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   817
      apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   818
  done    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   819
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   820
  case (NMTIMES r n m)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   821
  have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<Turnstile> v : r \<and> flat v = s" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   822
  have "s \<in> L (NMTIMES r n m)" by fact 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   823
  then obtain ss1 ss2 k where "concat (ss1 @ ss2) = s" "length (ss1 @ ss2) = k" "n \<le> k" "k \<le> m" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   824
    "\<forall>s \<in> set ss1. s \<in> L r \<and> s \<noteq> []" "\<forall>s \<in> set ss2. s \<in> L r \<and> s = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   825
  using Pow_cstring by (auto, blast)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   826
  then obtain vs1 vs2 where "flats (vs1 @ vs2) = s" "length (vs1 @ vs2) = k" "n \<le> k" "k \<le> m"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   827
      "\<forall>v\<in>set vs1. \<Turnstile> v : r \<and> flat v \<noteq> []" "\<forall>v\<in>set vs2. \<Turnstile> v : r \<and> flat v = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   828
  using IH flats_cval 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   829
  apply -
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   830
  apply(drule_tac x="ss1 @ ss2" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   831
  apply(drule_tac x="r" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   832
  apply(drule meta_mp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   833
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   834
  apply (metis Un_iff)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   835
  apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   836
  apply(drule_tac x="vs1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   837
  apply(drule_tac x="vs2" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   838
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   839
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   840
  then show "\<exists>v. \<Turnstile> v : NMTIMES r n m \<and> flat v = s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   841
    apply(case_tac "length vs1 \<le> n")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   842
  apply(rule_tac x="Stars (vs1 @ take (n - length vs1) vs2)" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   843
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   844
  apply(subgoal_tac "flats (take (n - length vs1) vs2) = []")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   845
  prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   846
  apply (meson flats_empty in_set_takeD)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   847
  apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   848
    apply(rule conjI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   849
      apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   850
        apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   851
       apply (meson in_set_takeD)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   852
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   853
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   854
     apply (simp add: flats_empty)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   855
      apply(rule_tac x="Stars vs1" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   856
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   857
    apply(rule conjI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   858
     apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   859
      apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   860
  done    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   861
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   862
  case (UPNTIMES r n s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   863
  have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<Turnstile> v : r \<and> flat v = s" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   864
  have "s \<in> L (UPNTIMES r n)" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   865
  then obtain ss where "concat ss = s" "\<forall>s \<in> set ss. s \<in> L r \<and> s \<noteq> []" "length ss \<le> n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   866
  using Pow_cstring_nonempty by force
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   867
  then obtain vs where "flats vs = s" "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> flat v \<noteq> []" "length vs \<le> n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   868
  using IH flats_cval_nonempty by (smt order.trans) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   869
  then show "\<exists>v. \<Turnstile> v : UPNTIMES r n \<and> flat v = s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   870
  using Prf.intros(7) flat_Stars by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   871
qed (auto intro: Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   872
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   873
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   874
lemma L_flat_Prf:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   875
  shows "L(r) = {flat v | v. \<Turnstile> v : r}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   876
using L_flat_Prf1 L_flat_Prf2 by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   877
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   878
thm Prf.intros
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   879
thm Prf.cases
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   880
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   881
lemma
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   882
  assumes "\<Turnstile> v : (STAR r)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   883
  shows "\<Turnstile> v : (FROMNTIMES r 0)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   884
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   885
  apply(erule_tac Prf.cases)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   886
             apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   887
  apply(case_tac vs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   888
   apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   889
  apply(subst append_Nil[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   890
   apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   891
     apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   892
  apply(simp add: Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   893
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   894
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   895
lemma
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   896
  assumes "\<Turnstile> v : (FROMNTIMES r 0)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   897
  shows "\<Turnstile> v : (STAR r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   898
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   899
  apply(erule_tac Prf.cases)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   900
             apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   901
   apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   902
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   903
  apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   904
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   905
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   906
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   907
section {* Sets of Lexical Values *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   908
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   909
text {*
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   910
  Shows that lexical values are finite for a given regex and string.
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   911
*}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   912
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   913
definition
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   914
  LV :: "rexp \<Rightarrow> string \<Rightarrow> val set"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   915
where  "LV r s \<equiv> {v. \<Turnstile> v : r \<and> flat v = s}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   916
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   917
lemma LV_simps:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   918
  shows "LV ZERO s = {}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   919
  and   "LV ONE s = (if s = [] then {Void} else {})"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   920
  and   "LV (CHAR c) s = (if s = [c] then {Char c} else {})"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   921
  and   "LV (ALT r1 r2) s = Left ` LV r1 s \<union> Right ` LV r2 s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   922
unfolding LV_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   923
apply(auto intro: Prf.intros elim: Prf.cases)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   924
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   925
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   926
abbreviation
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   927
  "Prefixes s \<equiv> {s'. prefix s' s}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   928
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   929
abbreviation
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   930
  "Suffixes s \<equiv> {s'. suffix s' s}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   931
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   932
abbreviation
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   933
  "SSuffixes s \<equiv> {s'. strict_suffix s' s}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   934
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   935
lemma Suffixes_cons [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   936
  shows "Suffixes (c # s) = Suffixes s \<union> {c # s}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   937
by (auto simp add: suffix_def Cons_eq_append_conv)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   938
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   939
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   940
lemma finite_Suffixes: 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   941
  shows "finite (Suffixes s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   942
by (induct s) (simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   943
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   944
lemma finite_SSuffixes: 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   945
  shows "finite (SSuffixes s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   946
proof -
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   947
  have "SSuffixes s \<subseteq> Suffixes s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   948
   unfolding suffix_def strict_suffix_def by auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   949
  then show "finite (SSuffixes s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   950
   using finite_Suffixes finite_subset by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   951
qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   952
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   953
lemma finite_Prefixes: 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   954
  shows "finite (Prefixes s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   955
proof -
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   956
  have "finite (Suffixes (rev s))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   957
    by (rule finite_Suffixes)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   958
  then have "finite (rev ` Suffixes (rev s))" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   959
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   960
  have "rev ` (Suffixes (rev s)) = Prefixes s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   961
  unfolding suffix_def prefix_def image_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   962
   by (auto)(metis rev_append rev_rev_ident)+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   963
  ultimately show "finite (Prefixes s)" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   964
qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   965
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   966
definition
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   967
  "Stars_Cons V Vs \<equiv> {Stars (v # vs) | v vs. v \<in> V \<and> Stars vs \<in> Vs}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   968
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   969
definition
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   970
  "Stars_Append Vs1 Vs2 \<equiv> {Stars (vs1 @ vs2) | vs1 vs2. Stars vs1 \<in> Vs1 \<and> Stars vs2 \<in> Vs2}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   971
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   972
fun Stars_Pow :: "val set \<Rightarrow> nat \<Rightarrow> val set"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   973
where  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   974
  "Stars_Pow Vs 0 = {Stars []}"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   975
| "Stars_Pow Vs (Suc n) = Stars_Cons Vs (Stars_Pow Vs n)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   976
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   977
lemma finite_Stars_Cons:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   978
  assumes "finite V" "finite Vs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   979
  shows "finite (Stars_Cons V Vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   980
  using assms  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   981
proof -
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   982
  from assms(2) have "finite (Stars -` Vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   983
    by(simp add: finite_vimageI inj_on_def) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   984
  with assms(1) have "finite (V \<times> (Stars -` Vs))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   985
    by(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   986
  then have "finite ((\<lambda>(v, vs). Stars (v # vs)) ` (V \<times> (Stars -` Vs)))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   987
    by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   988
  moreover have "Stars_Cons V Vs = (\<lambda>(v, vs). Stars (v # vs)) ` (V \<times> (Stars -` Vs))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   989
    unfolding Stars_Cons_def by auto    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   990
  ultimately show "finite (Stars_Cons V Vs)"   
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   991
    by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   992
qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   993
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   994
lemma finite_Stars_Append:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   995
  assumes "finite Vs1" "finite Vs2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   996
  shows "finite (Stars_Append Vs1 Vs2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   997
  using assms  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   998
proof -
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   999
  define UVs1 where "UVs1 \<equiv> Stars -` Vs1"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1000
  define UVs2 where "UVs2 \<equiv> Stars -` Vs2"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1001
  from assms have "finite UVs1" "finite UVs2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1002
    unfolding UVs1_def UVs2_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1003
    by(simp_all add: finite_vimageI inj_on_def) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1004
  then have "finite ((\<lambda>(vs1, vs2). Stars (vs1 @ vs2)) ` (UVs1 \<times> UVs2))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1005
    by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1006
  moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1007
    have "Stars_Append Vs1 Vs2 = (\<lambda>(vs1, vs2). Stars (vs1 @ vs2)) ` (UVs1 \<times> UVs2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1008
    unfolding Stars_Append_def UVs1_def UVs2_def by auto    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1009
  ultimately show "finite (Stars_Append Vs1 Vs2)"   
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1010
    by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1011
qed 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1012
 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1013
lemma finite_Stars_Pow:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1014
  assumes "finite Vs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1015
  shows "finite (Stars_Pow Vs n)"    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1016
by (induct n) (simp_all add: finite_Stars_Cons assms)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1017
    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1018
lemma LV_STAR_finite:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1019
  assumes "\<forall>s. finite (LV r s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1020
  shows "finite (LV (STAR r) s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1021
proof(induct s rule: length_induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1022
  fix s::"char list"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1023
  assume "\<forall>s'. length s' < length s \<longrightarrow> finite (LV (STAR r) s')"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1024
  then have IH: "\<forall>s' \<in> SSuffixes s. finite (LV (STAR r) s')"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1025
    apply(auto simp add: strict_suffix_def suffix_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1026
    by force    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1027
  define f where "f \<equiv> \<lambda>(v, vs). Stars (v # vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1028
  define S1 where "S1 \<equiv> \<Union>s' \<in> Prefixes s. LV r s'"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1029
  define S2 where "S2 \<equiv> \<Union>s2 \<in> SSuffixes s. LV (STAR r) s2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1030
  have "finite S1" using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1031
    unfolding S1_def by (simp_all add: finite_Prefixes)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1032
  moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1033
  with IH have "finite S2" unfolding S2_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1034
    by (auto simp add: finite_SSuffixes)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1035
  ultimately 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1036
  have "finite ({Stars []} \<union> Stars_Cons S1 S2)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1037
    by (simp add: finite_Stars_Cons)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1038
  moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1039
  have "LV (STAR r) s \<subseteq> {Stars []} \<union> (Stars_Cons S1 S2)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1040
  unfolding S1_def S2_def f_def LV_def Stars_Cons_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1041
  unfolding prefix_def strict_suffix_def 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1042
  unfolding image_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1043
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1044
  apply(case_tac x)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1045
  apply(auto elim: Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1046
  apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1047
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1048
  apply(case_tac vs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1049
  apply(auto intro: Prf.intros)  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1050
  apply(rule exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1051
  apply(rule conjI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1052
  apply(rule_tac x="flats list" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1053
   apply(rule conjI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1054
  apply(simp add: suffix_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1055
  apply(blast)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1056
  using Prf.intros(6) flat_Stars by blast  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1057
  ultimately
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1058
  show "finite (LV (STAR r) s)" by (simp add: finite_subset)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1059
qed  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1060
    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1061
lemma LV_UPNTIMES_STAR:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1062
  "LV (UPNTIMES r n) s \<subseteq> LV (STAR r) s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1063
by(auto simp add: LV_def intro: Prf.intros elim: Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1064
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1065
lemma LV_NTIMES_3:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1066
  shows "LV (NTIMES r (Suc n)) [] = (\<lambda>(v,vs). Stars (v#vs)) ` (LV r [] \<times> (Stars -` (LV (NTIMES r n) [])))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1067
unfolding LV_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1068
apply(auto elim!: Prf_elims simp add: image_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1069
apply(case_tac vs1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1070
apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1071
apply(case_tac vs2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1072
apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1073
apply(subst append.simps(1)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1074
apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1075
apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1076
apply(subst append.simps(1)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1077
apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1078
apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1079
  done 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1080
    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1081
lemma LV_FROMNTIMES_3:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1082
  shows "LV (FROMNTIMES r (Suc n)) [] = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1083
    (\<lambda>(v,vs). Stars (v#vs)) ` (LV r [] \<times> (Stars -` (LV (FROMNTIMES r n) [])))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1084
unfolding LV_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1085
apply(auto elim!: Prf_elims simp add: image_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1086
apply(case_tac vs1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1087
apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1088
apply(case_tac vs2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1089
apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1090
apply(subst append.simps(1)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1091
apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1092
     apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1093
  apply (metis le_imp_less_Suc length_greater_0_conv less_antisym list.exhaust list.set_intros(1) not_less_eq zero_le)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1094
  prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1095
  using nth_mem apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1096
  apply(case_tac vs1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1097
  apply (smt Groups.add_ac(2) Prf.intros(9) add.right_neutral add_Suc_right append.simps(1) insert_iff length_append list.set(2) list.size(3) list.size(4))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1098
    apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1099
done     
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1100
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1101
lemma LV_NTIMES_4:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1102
 "LV (NTIMES r n) [] = Stars_Pow (LV r []) n" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1103
  apply(induct n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1104
   apply(simp add: LV_def)    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1105
   apply(auto elim!: Prf_elims simp add: image_def)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1106
   apply(subst append.simps[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1107
    apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1108
      apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1109
    apply(simp add: LV_NTIMES_3 image_def Stars_Cons_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1110
  apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1111
 done   
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1112
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1113
lemma LV_NTIMES_5:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1114
  "LV (NTIMES r n) s \<subseteq> Stars_Append (LV (STAR r) s) (\<Union>i\<le>n. LV (NTIMES r i) [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1115
apply(auto simp add: LV_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1116
apply(auto elim!: Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1117
  apply(auto simp add: Stars_Append_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1118
  apply(rule_tac x="vs1" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1119
  apply(rule_tac x="vs2" in exI)  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1120
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1121
    using Prf.intros(6) apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1122
      apply(rule_tac x="length vs2" in bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1123
    thm Prf.intros
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1124
      apply(subst append.simps(1)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1125
    apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1126
      apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1127
      apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1128
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1129
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1130
      done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1131
      
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1132
lemma ttty:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1133
 "LV (FROMNTIMES r n) [] = Stars_Pow (LV r []) n" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1134
  apply(induct n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1135
   apply(simp add: LV_def)    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1136
   apply(auto elim: Prf_elims simp add: image_def)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1137
   prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1138
    apply(subst append.simps[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1139
    apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1140
      apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1141
   apply(erule Prf_elims) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1142
    apply(case_tac vs1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1143
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1144
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1145
   apply(case_tac x)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1146
    apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1147
    apply(simp add: LV_FROMNTIMES_3 image_def Stars_Cons_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1148
  apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1149
 done     
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1150
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1151
lemma LV_FROMNTIMES_5:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1152
  "LV (FROMNTIMES r n) s \<subseteq> Stars_Append (LV (STAR r) s) (\<Union>i\<le>n. LV (FROMNTIMES r i) [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1153
apply(auto simp add: LV_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1154
apply(auto elim!: Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1155
  apply(auto simp add: Stars_Append_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1156
  apply(rule_tac x="vs1" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1157
  apply(rule_tac x="vs2" in exI)  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1158
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1159
    using Prf.intros(6) apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1160
      apply(rule_tac x="length vs2" in bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1161
    thm Prf.intros
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1162
      apply(subst append.simps(1)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1163
    apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1164
      apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1165
      apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1166
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1167
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1168
      apply(rule_tac x="vs" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1169
    apply(rule_tac x="[]" in exI) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1170
    apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1171
    by (metis Prf.intros(9) append_Nil atMost_iff empty_iff le_imp_less_Suc less_antisym list.set(1) nth_mem zero_le)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1172
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1173
lemma LV_FROMNTIMES_6:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1174
  assumes "\<forall>s. finite (LV r s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1175
  shows "finite (LV (FROMNTIMES r n) s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1176
  apply(rule finite_subset)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1177
   apply(rule LV_FROMNTIMES_5)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1178
  apply(rule finite_Stars_Append)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1179
    apply(rule LV_STAR_finite)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1180
   apply(rule assms)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1181
  apply(rule finite_UN_I)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1182
   apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1183
  by (simp add: assms finite_Stars_Pow ttty)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1184
    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1185
lemma LV_NMTIMES_5:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1186
  "LV (NMTIMES r n m) s \<subseteq> Stars_Append (LV (STAR r) s) (\<Union>i\<le>n. LV (FROMNTIMES r i) [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1187
apply(auto simp add: LV_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1188
apply(auto elim!: Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1189
  apply(auto simp add: Stars_Append_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1190
  apply(rule_tac x="vs1" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1191
  apply(rule_tac x="vs2" in exI)  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1192
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1193
    using Prf.intros(6) apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1194
      apply(rule_tac x="length vs2" in bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1195
    thm Prf.intros
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1196
      apply(subst append.simps(1)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1197
    apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1198
      apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1199
      apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1200
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1201
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1202
      apply(rule_tac x="vs" in exI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1203
    apply(rule_tac x="[]" in exI) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1204
    apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1205
    by (metis Prf.intros(9) append_Nil atMost_iff empty_iff le_imp_less_Suc less_antisym list.set(1) nth_mem zero_le)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1206
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1207
lemma LV_NMTIMES_6:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1208
  assumes "\<forall>s. finite (LV r s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1209
  shows "finite (LV (NMTIMES r n m) s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1210
  apply(rule finite_subset)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1211
   apply(rule LV_NMTIMES_5)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1212
  apply(rule finite_Stars_Append)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1213
    apply(rule LV_STAR_finite)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1214
   apply(rule assms)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1215
  apply(rule finite_UN_I)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1216
   apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1217
  by (simp add: assms finite_Stars_Pow ttty)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1218
        
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1219
    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1220
lemma LV_finite:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1221
  shows "finite (LV r s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1222
proof(induct r arbitrary: s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1223
  case (ZERO s) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1224
  show "finite (LV ZERO s)" by (simp add: LV_simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1225
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1226
  case (ONE s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1227
  show "finite (LV ONE s)" by (simp add: LV_simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1228
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1229
  case (CHAR c s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1230
  show "finite (LV (CHAR c) s)" by (simp add: LV_simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1231
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1232
  case (ALT r1 r2 s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1233
  then show "finite (LV (ALT r1 r2) s)" by (simp add: LV_simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1234
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1235
  case (SEQ r1 r2 s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1236
  define f where "f \<equiv> \<lambda>(v1, v2). Seq v1 v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1237
  define S1 where "S1 \<equiv> \<Union>s' \<in> Prefixes s. LV r1 s'"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1238
  define S2 where "S2 \<equiv> \<Union>s' \<in> Suffixes s. LV r2 s'"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1239
  have IHs: "\<And>s. finite (LV r1 s)" "\<And>s. finite (LV r2 s)" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1240
  then have "finite S1" "finite S2" unfolding S1_def S2_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1241
    by (simp_all add: finite_Prefixes finite_Suffixes)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1242
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1243
  have "LV (SEQ r1 r2) s \<subseteq> f ` (S1 \<times> S2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1244
    unfolding f_def S1_def S2_def 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1245
    unfolding LV_def image_def prefix_def suffix_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1246
    apply (auto elim!: Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1247
    by (metis (mono_tags, lifting) mem_Collect_eq)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1248
  ultimately 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1249
  show "finite (LV (SEQ r1 r2) s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1250
    by (simp add: finite_subset)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1251
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1252
  case (STAR r s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1253
  then show "finite (LV (STAR r) s)" by (simp add: LV_STAR_finite)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1254
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1255
  case (UPNTIMES r n s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1256
  have "\<And>s. finite (LV r s)" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1257
  then show "finite (LV (UPNTIMES r n) s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1258
  by (meson LV_STAR_finite LV_UPNTIMES_STAR rev_finite_subset)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1259
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1260
  case (FROMNTIMES r n s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1261
  have "\<And>s. finite (LV r s)" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1262
  then show "finite (LV (FROMNTIMES r n) s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1263
    by (simp add: LV_FROMNTIMES_6)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1264
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1265
  case (NTIMES r n s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1266
  have "\<And>s. finite (LV r s)" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1267
  then show "finite (LV (NTIMES r n) s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1268
    by (metis (no_types, lifting) LV_NTIMES_4 LV_NTIMES_5 LV_STAR_finite finite_Stars_Append finite_Stars_Pow finite_UN_I finite_atMost finite_subset)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1269
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1270
  case (NMTIMES r n m s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1271
  have "\<And>s. finite (LV r s)" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1272
  then show "finite (LV (NMTIMES r n m) s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1273
    by (simp add: LV_NMTIMES_6)         
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1274
qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1275
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1276
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1277
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1278
section {* Our POSIX Definition *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1279
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1280
inductive 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1281
  Posix :: "string \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<in> _ \<rightarrow> _" [100, 100, 100] 100)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1282
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1283
  Posix_ONE: "[] \<in> ONE \<rightarrow> Void"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1284
| Posix_CHAR: "[c] \<in> (CHAR c) \<rightarrow> (Char c)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1285
| Posix_ALT1: "s \<in> r1 \<rightarrow> v \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Left v)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1286
| Posix_ALT2: "\<lbrakk>s \<in> r2 \<rightarrow> v; s \<notin> L(r1)\<rbrakk> \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Right v)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1287
| Posix_SEQ: "\<lbrakk>s1 \<in> r1 \<rightarrow> v1; s2 \<in> r2 \<rightarrow> v2;
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1288
    \<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r1 \<and> s\<^sub>4 \<in> L r2)\<rbrakk> \<Longrightarrow> 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1289
    (s1 @ s2) \<in> (SEQ r1 r2) \<rightarrow> (Seq v1 v2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1290
| Posix_STAR1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> STAR r \<rightarrow> Stars vs; flat v \<noteq> [];
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1291
    \<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))\<rbrakk>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1292
    \<Longrightarrow> (s1 @ s2) \<in> STAR r \<rightarrow> Stars (v # vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1293
| Posix_STAR2: "[] \<in> STAR r \<rightarrow> Stars []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1294
| Posix_NTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> NTIMES r (n - 1) \<rightarrow> Stars vs; flat v \<noteq> []; 0 < n;
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1295
    \<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (NTIMES r (n - 1)))\<rbrakk>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1296
    \<Longrightarrow> (s1 @ s2) \<in> NTIMES r n \<rightarrow> Stars (v # vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1297
| Posix_NTIMES2: "\<lbrakk>\<forall>v \<in> set vs. [] \<in> r \<rightarrow> v; length vs = n\<rbrakk>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1298
    \<Longrightarrow> [] \<in> NTIMES r n \<rightarrow> Stars vs"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1299
| Posix_UPNTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> UPNTIMES r (n - 1) \<rightarrow> Stars vs; flat v \<noteq> []; 0 < n;
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1300
    \<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (n - 1)))\<rbrakk>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1301
    \<Longrightarrow> (s1 @ s2) \<in> UPNTIMES r n \<rightarrow> Stars (v # vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1302
| Posix_UPNTIMES2: "[] \<in> UPNTIMES r n \<rightarrow> Stars []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1303
| Posix_FROMNTIMES2: "\<lbrakk>\<forall>v \<in> set vs. [] \<in> r \<rightarrow> v; length vs = n\<rbrakk>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1304
    \<Longrightarrow> [] \<in> FROMNTIMES r n \<rightarrow> Stars vs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1305
| Posix_FROMNTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> FROMNTIMES r (n - 1) \<rightarrow> Stars vs; flat v \<noteq> []; 0 < n;
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1306
    \<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (FROMNTIMES r (n - 1)))\<rbrakk>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1307
    \<Longrightarrow> (s1 @ s2) \<in> FROMNTIMES r n \<rightarrow> Stars (v # vs)"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1308
| Posix_FROMNTIMES3: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> STAR r \<rightarrow> Stars vs; flat v \<noteq> [];
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1309
    \<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))\<rbrakk>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1310
    \<Longrightarrow> (s1 @ s2) \<in> FROMNTIMES r 0 \<rightarrow> Stars (v # vs)"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1311
| Posix_NMTIMES2: "\<lbrakk>\<forall>v \<in> set vs. [] \<in> r \<rightarrow> v; length vs = n; n \<le> m\<rbrakk>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1312
    \<Longrightarrow> [] \<in> NMTIMES r n m \<rightarrow> Stars vs"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1313
| Posix_NMTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> NMTIMES r (n - 1) (m - 1) \<rightarrow> Stars vs; flat v \<noteq> []; 0 < n; n \<le> m;
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1314
    \<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (NMTIMES r (n - 1) (m - 1)))\<rbrakk>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1315
    \<Longrightarrow> (s1 @ s2) \<in> NMTIMES r n m \<rightarrow> Stars (v # vs)"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1316
| Posix_NMTIMES3: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> UPNTIMES r (m - 1) \<rightarrow> Stars vs; flat v \<noteq> []; 0 < m;
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1317
    \<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (m - 1)))\<rbrakk>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1318
    \<Longrightarrow> (s1 @ s2) \<in> NMTIMES r 0 m \<rightarrow> Stars (v # vs)"    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1319
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1320
inductive_cases Posix_elims:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1321
  "s \<in> ZERO \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1322
  "s \<in> ONE \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1323
  "s \<in> CHAR c \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1324
  "s \<in> ALT r1 r2 \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1325
  "s \<in> SEQ r1 r2 \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1326
  "s \<in> STAR r \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1327
  "s \<in> NTIMES r n \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1328
  "s \<in> UPNTIMES r n \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1329
  "s \<in> FROMNTIMES r n \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1330
  "s \<in> NMTIMES r n m \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1331
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1332
lemma Posix1:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1333
  assumes "s \<in> r \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1334
  shows "s \<in> L r" "flat v = s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1335
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1336
  apply(induct s r v rule: Posix.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1337
                    apply(auto simp add: Sequ_def)[18]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1338
            apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1339
             apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1340
  apply(simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1341
            apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1342
           apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1343
  apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1344
  apply(rule_tac x="Suc x" in bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1345
  apply(simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1346
            apply(auto)[5]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1347
  using nth_mem nullable.simps(9) nullable_correctness apply auto[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1348
  apply simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1349
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1350
       apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1351
       apply(rule_tac x="Suc x" in bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1352
        apply(simp add: Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1353
          apply(auto)[3]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1354
    defer
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1355
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1356
  apply fastforce
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1357
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1358
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1359
    apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1360
   apply(rule_tac x="Suc x" in bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1361
    apply(auto simp add: Sequ_def)[2]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1362
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1363
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1364
    apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1365
     apply(rule_tac x="Suc x" in bexI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1366
    apply(auto simp add: Sequ_def)[2]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1367
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1368
  apply(simp add: Star.step Star_Pow)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1369
done  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1370
    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1371
text {*
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1372
  Our Posix definition determines a unique value.
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1373
*}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1374
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1375
lemma List_eq_zipI:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1376
  assumes "\<forall>(v1, v2) \<in> set (zip vs1 vs2). v1 = v2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1377
  and "length vs1 = length vs2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1378
  shows "vs1 = vs2"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1379
 using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1380
  apply(induct vs1 arbitrary: vs2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1381
   apply(case_tac vs2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1382
   apply(simp)    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1383
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1384
   apply(case_tac vs2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1385
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1386
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1387
done    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1388
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1389
lemma Posix_determ:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1390
  assumes "s \<in> r \<rightarrow> v1" "s \<in> r \<rightarrow> v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1391
  shows "v1 = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1392
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1393
proof (induct s r v1 arbitrary: v2 rule: Posix.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1394
  case (Posix_ONE v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1395
  have "[] \<in> ONE \<rightarrow> v2" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1396
  then show "Void = v2" by cases auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1397
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1398
  case (Posix_CHAR c v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1399
  have "[c] \<in> CHAR c \<rightarrow> v2" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1400
  then show "Char c = v2" by cases auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1401
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1402
  case (Posix_ALT1 s r1 v r2 v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1403
  have "s \<in> ALT r1 r2 \<rightarrow> v2" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1404
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1405
  have "s \<in> r1 \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1406
  then have "s \<in> L r1" by (simp add: Posix1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1407
  ultimately obtain v' where eq: "v2 = Left v'" "s \<in> r1 \<rightarrow> v'" by cases auto 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1408
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1409
  have IH: "\<And>v2. s \<in> r1 \<rightarrow> v2 \<Longrightarrow> v = v2" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1410
  ultimately have "v = v'" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1411
  then show "Left v = v2" using eq by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1412
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1413
  case (Posix_ALT2 s r2 v r1 v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1414
  have "s \<in> ALT r1 r2 \<rightarrow> v2" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1415
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1416
  have "s \<notin> L r1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1417
  ultimately obtain v' where eq: "v2 = Right v'" "s \<in> r2 \<rightarrow> v'" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1418
    by cases (auto simp add: Posix1) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1419
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1420
  have IH: "\<And>v2. s \<in> r2 \<rightarrow> v2 \<Longrightarrow> v = v2" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1421
  ultimately have "v = v'" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1422
  then show "Right v = v2" using eq by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1423
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1424
  case (Posix_SEQ s1 r1 v1 s2 r2 v2 v')
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1425
  have "(s1 @ s2) \<in> SEQ r1 r2 \<rightarrow> v'" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1426
       "s1 \<in> r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1427
       "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1428
  then obtain v1' v2' where "v' = Seq v1' v2'" "s1 \<in> r1 \<rightarrow> v1'" "s2 \<in> r2 \<rightarrow> v2'"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1429
  apply(cases) apply (auto simp add: append_eq_append_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1430
  using Posix1(1) by fastforce+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1431
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1432
  have IHs: "\<And>v1'. s1 \<in> r1 \<rightarrow> v1' \<Longrightarrow> v1 = v1'"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1433
            "\<And>v2'. s2 \<in> r2 \<rightarrow> v2' \<Longrightarrow> v2 = v2'" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1434
  ultimately show "Seq v1 v2 = v'" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1435
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1436
  case (Posix_STAR1 s1 r v s2 vs v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1437
  have "(s1 @ s2) \<in> STAR r \<rightarrow> v2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1438
       "s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" "flat v \<noteq> []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1439
       "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1440
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (STAR r) \<rightarrow> (Stars vs')"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1441
  apply(cases) apply (auto simp add: append_eq_append_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1442
  using Posix1(1) apply fastforce
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1443
  apply (metis Posix1(1) Posix_STAR1.hyps(6) append_Nil append_Nil2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1444
  using Posix1(2) by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1445
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1446
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1447
            "\<And>v2. s2 \<in> STAR r \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1448
  ultimately show "Stars (v # vs) = v2" by auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1449
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1450
  case (Posix_STAR2 r v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1451
  have "[] \<in> STAR r \<rightarrow> v2" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1452
  then show "Stars [] = v2" by cases (auto simp add: Posix1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1453
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1454
  case (Posix_NTIMES2 vs r n v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1455
  then show "Stars vs = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1456
    apply(erule_tac Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1457
     apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1458
     apply (simp add: Posix1(2))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1459
    apply(rule List_eq_zipI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1460
     apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1461
    by (meson in_set_zipE)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1462
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1463
  case (Posix_NTIMES1 s1 r v s2 n vs v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1464
  have "(s1 @ s2) \<in> NTIMES r n \<rightarrow> v2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1465
       "s1 \<in> r \<rightarrow> v" "s2 \<in> NTIMES r (n - 1) \<rightarrow> Stars vs" "flat v \<noteq> []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1466
       "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (NTIMES r (n - 1 )))" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1467
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (NTIMES r (n - 1)) \<rightarrow> (Stars vs')"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1468
  apply(cases) apply (auto simp add: append_eq_append_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1469
    using Posix1(1) apply fastforce
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1470
    apply (metis One_nat_def Posix1(1) Posix_NTIMES1.hyps(7) append.right_neutral append_self_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1471
  using Posix1(2) by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1472
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1473
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1474
            "\<And>v2. s2 \<in> NTIMES r (n - 1) \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1475
  ultimately show "Stars (v # vs) = v2" by auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1476
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1477
  case (Posix_UPNTIMES1 s1 r v s2 n vs v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1478
  have "(s1 @ s2) \<in> UPNTIMES r n \<rightarrow> v2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1479
       "s1 \<in> r \<rightarrow> v" "s2 \<in> UPNTIMES r (n - 1) \<rightarrow> Stars vs" "flat v \<noteq> []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1480
       "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (n - 1 )))" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1481
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (UPNTIMES r (n - 1)) \<rightarrow> (Stars vs')"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1482
  apply(cases) apply (auto simp add: append_eq_append_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1483
    using Posix1(1) apply fastforce
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1484
    apply (metis One_nat_def Posix1(1) Posix_UPNTIMES1.hyps(7) append.right_neutral append_self_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1485
  using Posix1(2) by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1486
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1487
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1488
            "\<And>v2. s2 \<in> UPNTIMES r (n - 1) \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1489
  ultimately show "Stars (v # vs) = v2" by auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1490
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1491
  case (Posix_UPNTIMES2 r n v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1492
  then show "Stars [] = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1493
    apply(erule_tac Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1494
     apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1495
    by (simp add: Posix1(2))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1496
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1497
  case (Posix_FROMNTIMES1 s1 r v s2 n vs v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1498
  have "(s1 @ s2) \<in> FROMNTIMES r n \<rightarrow> v2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1499
       "s1 \<in> r \<rightarrow> v" "s2 \<in> FROMNTIMES r (n - 1) \<rightarrow> Stars vs" "flat v \<noteq> []" "0 < n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1500
       "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (FROMNTIMES r (n - 1 )))" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1501
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (FROMNTIMES r (n - 1)) \<rightarrow> (Stars vs')"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1502
  apply(cases) apply (auto simp add: append_eq_append_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1503
    using Posix1(1) Posix1(2) apply blast 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1504
     apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1505
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1506
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1507
    apply(drule_tac x="va" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1508
    apply(drule_tac x="vs" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1509
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1510
     apply(drule meta_mp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1511
    apply (metis L.simps(9) Posix1(1) UN_E append.right_neutral append_Nil diff_Suc_1 local.Posix_FROMNTIMES1(4) val.inject(5))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1512
    apply (metis L.simps(9) Posix1(1) UN_E append.right_neutral append_Nil)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1513
    by (metis One_nat_def Posix1(1) Posix_FROMNTIMES1.hyps(7) self_append_conv self_append_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1514
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1515
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1516
            "\<And>v2. s2 \<in> FROMNTIMES r (n - 1) \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1517
  ultimately show "Stars (v # vs) = v2" by auto    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1518
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1519
  case (Posix_FROMNTIMES2 vs r n v2)  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1520
  then show "Stars vs = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1521
    apply(erule_tac Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1522
     apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1523
    apply(rule List_eq_zipI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1524
     apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1525
      apply(meson in_set_zipE)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1526
     apply (simp add: Posix1(2))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1527
    using Posix1(2) by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1528
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1529
  case (Posix_FROMNTIMES3 s1 r v s2 vs v2)  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1530
    have "(s1 @ s2) \<in> FROMNTIMES r 0 \<rightarrow> v2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1531
       "s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" "flat v \<noteq> []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1532
       "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1533
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (STAR r) \<rightarrow> (Stars vs')"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1534
  apply(cases) apply (auto simp add: append_eq_append_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1535
    using Posix1(2) apply fastforce
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1536
    using Posix1(1) apply fastforce
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1537
    by (metis Posix1(1) Posix_FROMNTIMES3.hyps(6) append.right_neutral append_Nil)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1538
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1539
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1540
            "\<And>v2. s2 \<in> STAR r \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1541
  ultimately show "Stars (v # vs) = v2" by auto     
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1542
next    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1543
  case (Posix_NMTIMES1 s1 r v s2 n m vs v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1544
  have "(s1 @ s2) \<in> NMTIMES r n m \<rightarrow> v2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1545
       "s1 \<in> r \<rightarrow> v" "s2 \<in> NMTIMES r (n - 1) (m - 1) \<rightarrow> Stars vs" "flat v \<noteq> []" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1546
       "0 < n" "n \<le> m"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1547
       "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (NMTIMES r (n - 1) (m - 1)))" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1548
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1549
    "s2 \<in> (NMTIMES r (n - 1) (m - 1)) \<rightarrow> (Stars vs')"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1550
  apply(cases) apply (auto simp add: append_eq_append_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1551
    using Posix1(1) Posix1(2) apply blast 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1552
     apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1553
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1554
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1555
       apply(case_tac m)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1556
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1557
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1558
    apply(drule_tac x="va" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1559
    apply(drule_tac x="vs" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1560
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1561
     apply(drule meta_mp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1562
      apply(drule Posix1(1))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1563
      apply(drule Posix1(1))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1564
      apply(drule Posix1(1))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1565
      apply(frule Posix1(1))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1566
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1567
    using Posix_NMTIMES1.hyps(4) apply force
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1568
     apply (metis L.simps(10) Posix1(1) UN_E append_Nil2 append_self_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1569
    by (metis One_nat_def Posix1(1) Posix_NMTIMES1.hyps(8) append.right_neutral append_Nil)      
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1570
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1571
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1572
            "\<And>v2. s2 \<in> NMTIMES r (n - 1) (m - 1) \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1573
  ultimately show "Stars (v # vs) = v2" by auto     
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1574
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1575
  case (Posix_NMTIMES2 vs r n m v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1576
  then show "Stars vs = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1577
    apply(erule_tac Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1578
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1579
      apply(rule List_eq_zipI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1580
       apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1581
      apply (meson in_set_zipE)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1582
    apply (simp add: Posix1(2))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1583
    apply(erule_tac Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1584
     apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1585
    apply (simp add: Posix1(2))+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1586
    done  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1587
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1588
  case (Posix_NMTIMES3 s1 r v s2 m vs v2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1589
   have "(s1 @ s2) \<in> NMTIMES r 0 m \<rightarrow> v2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1590
       "s1 \<in> r \<rightarrow> v" "s2 \<in> UPNTIMES r (m - 1) \<rightarrow> Stars vs" "flat v \<noteq> []" "0 < m"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1591
       "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (m - 1 )))" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1592
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (UPNTIMES r (m - 1)) \<rightarrow> (Stars vs')"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1593
    apply(cases) apply (auto simp add: append_eq_append_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1594
    using Posix1(2) apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1595
    apply (smt L.simps(7) Posix1(1) UN_E append_eq_append_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1596
    by (metis One_nat_def Posix1(1) Posix_NMTIMES3.hyps(7) append.right_neutral append_Nil)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1597
  moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1598
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1599
            "\<And>v2. s2 \<in> UPNTIMES r (m - 1) \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1600
  ultimately show "Stars (v # vs) = v2" by auto  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1601
qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1602
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1603
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1604
text {*
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1605
  Our POSIX value is a lexical value.
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1606
*}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1607
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1608
lemma Posix_LV:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1609
  assumes "s \<in> r \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1610
  shows "v \<in> LV r s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1611
using assms unfolding LV_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1612
apply(induct rule: Posix.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1613
            apply(auto simp add: intro!: Prf.intros elim!: Prf_elims)[7]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1614
     defer
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1615
  defer
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1616
     apply(auto simp add: intro!: Prf.intros elim!: Prf_elims)[2]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1617
  apply (metis (mono_tags, lifting) Prf.intros(9) append_Nil empty_iff flat_Stars flats_empty list.set(1) mem_Collect_eq)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1618
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1619
     apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1620
     apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1621
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1622
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1623
     apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1624
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1625
  apply(subst append.simps(2)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1626
      apply(rule Prf.intros) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1627
        apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1628
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1629
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1630
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1631
     apply(rule Prf.intros)  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1632
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1633
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1634
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1635
   apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1636
   apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1637
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1638
  apply(rule Prf.intros)  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1639
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1640
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1641
  (* NTIMES *)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1642
   prefer 4
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1643
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1644
   apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1645
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1646
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1647
   apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1648
   apply(rotate_tac 5)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1649
   apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1650
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1651
  apply(subst append.simps(2)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1652
      apply(rule Prf.intros) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1653
        apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1654
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1655
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1656
  prefer 4
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1657
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1658
  apply (metis Prf.intros(8) length_removeAll_less less_irrefl_nat removeAll.simps(1) self_append_conv2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1659
  (* NMTIMES *)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1660
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1661
  apply (metis Prf.intros(11) append_Nil empty_iff list.set(1))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1662
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1663
  apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1664
  apply(rotate_tac 6)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1665
  apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1666
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1667
  apply(subst append.simps(2)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1668
      apply(rule Prf.intros) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1669
        apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1670
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1671
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1672
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1673
  apply(rule Prf.intros) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1674
        apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1675
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1676
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1677
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1678
  apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1679
  apply(rotate_tac 6)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1680
  apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1681
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1682
      apply(rule Prf.intros) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1683
        apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1684
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1685
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1686
done    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1687
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1688
end