thys/LexerExt.thy
author Christian Urban <urbanc@in.tum.de>
Mon, 20 Mar 2017 15:13:17 +0000
changeset 239 e59cec211f4f
parent 238 2dc1647eab9e
child 243 09ab631ce7fa
permissions -rw-r--r--
added automata implementation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
   
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
     2
theory LexerExt
185
841f7b9c0a6a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 172
diff changeset
     3
  imports Main
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
begin
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
     7
section {* Sequential Composition of Languages *}
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
definition
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
  Sequ :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ;; _" [100,100] 100)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
where 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
  "A ;; B = {s1 @ s2 | s1 s2. s1 \<in> A \<and> s2 \<in> B}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
text {* Two Simple Properties about Sequential Composition *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    16
lemma Sequ_empty [simp]:
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
  shows "A ;; {[]} = A"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
  and   "{[]} ;; A = A"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
by (simp_all add: Sequ_def)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    21
lemma Sequ_null [simp]:
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
  shows "A ;; {} = {}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
  and   "{} ;; A = {}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
by (simp_all add: Sequ_def)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    26
lemma Sequ_assoc: 
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    27
  shows "A ;; (B ;; C) = (A ;; B) ;; C"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    28
apply(auto simp add: Sequ_def)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    29
apply(metis append_assoc)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    30
apply(metis)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    31
done
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    32
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    33
lemma Sequ_UNION: 
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    34
  shows "(\<Union>x\<in>A. B ;; C x) = B ;; (\<Union>x\<in>A. C x)"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    35
by (auto simp add: Sequ_def)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    36
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    37
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
    38
section {* Semantic Derivative (Left Quotient) of Languages *}
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    39
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    40
definition
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    41
  Der :: "char \<Rightarrow> string set \<Rightarrow> string set"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    42
where
112
698967eceaf1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 111
diff changeset
    43
  "Der c A \<equiv> {s. c # s \<in> A}"
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    44
204
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    45
definition
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    46
  Ders :: "string \<Rightarrow> string set \<Rightarrow> string set"
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    47
where
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    48
  "Ders s A \<equiv> {s'. s @ s' \<in> A}"
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    49
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    50
lemma Der_null [simp]:
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    51
  shows "Der c {} = {}"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    52
unfolding Der_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    53
by auto
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    54
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    55
lemma Der_empty [simp]:
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    56
  shows "Der c {[]} = {}"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    57
unfolding Der_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    58
by auto
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    59
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    60
lemma Der_char [simp]:
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    61
  shows "Der c {[d]} = (if c = d then {[]} else {})"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    62
unfolding Der_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    63
by auto
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    64
229
81c85f2746f5 updated
Christian Urban <urbanc@in.tum.de>
parents: 228
diff changeset
    65
lemma Der_Sequ [simp]:
81c85f2746f5 updated
Christian Urban <urbanc@in.tum.de>
parents: 228
diff changeset
    66
  shows "Der c (A ;; B) = (Der c A) ;; B \<union> (if [] \<in> A then Der c B else {})"
81c85f2746f5 updated
Christian Urban <urbanc@in.tum.de>
parents: 228
diff changeset
    67
unfolding Der_def Sequ_def
81c85f2746f5 updated
Christian Urban <urbanc@in.tum.de>
parents: 228
diff changeset
    68
by (auto simp add: Cons_eq_append_conv)
81c85f2746f5 updated
Christian Urban <urbanc@in.tum.de>
parents: 228
diff changeset
    69
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
    70
lemma Der_inter [simp]:
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
    71
  shows "Der c (A \<inter> B) = Der c A \<inter> Der c B"
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
    72
unfolding Der_def
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
    73
by auto
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
    74
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    75
lemma Der_union [simp]:
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    76
  shows "Der c (A \<union> B) = Der c A \<union> Der c B"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    77
unfolding Der_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    78
by auto
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    79
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    80
lemma Der_UNION: 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    81
  shows "Der c (\<Union>x\<in>A. B x) = (\<Union>x\<in>A. Der c (B x))"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    82
by (auto simp add: Der_def)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    83
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    84
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    85
section {* Power operation for Sets *}
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    86
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    87
fun 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    88
  Pow :: "string set \<Rightarrow> nat \<Rightarrow> string set" ("_ \<up> _" [101, 102] 101)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    89
where
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    90
   "A \<up> 0 = {[]}"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    91
|  "A \<up> (Suc n) = A ;; (A \<up> n)"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    92
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    93
lemma Pow_empty [simp]:
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    94
  shows "[] \<in> A \<up> n \<longleftrightarrow> (n = 0 \<or> [] \<in> A)"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    95
by(induct n) (auto simp add: Sequ_def)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
    96
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    97
lemma Der_Pow [simp]:
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    98
  shows "Der c (A \<up> (Suc n)) = 
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    99
     (Der c A) ;; (A \<up> n) \<union> (if [] \<in> A then Der c (A \<up> n) else {})"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   100
unfolding Der_def Sequ_def 
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   101
by(auto simp add: Cons_eq_append_conv Sequ_def)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   102
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   103
lemma Der_Pow_subseteq:
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   104
  assumes "[] \<in> A"  
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   105
  shows "Der c (A \<up> n) \<subseteq> (Der c A) ;; (A \<up> n)"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   106
using assms
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   107
apply(induct n)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   108
apply(simp add: Sequ_def Der_def)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   109
apply(simp)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   110
apply(rule conjI)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   111
apply (smt Sequ_def append_Nil2 mem_Collect_eq Sequ_assoc subsetI)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   112
apply(subgoal_tac "((Der c A) ;; (A \<up> n)) \<subseteq> ((Der c A) ;; (A ;; (A \<up> n)))")
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   113
apply(auto)[1]
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   114
by (smt Sequ_def append_Nil2 mem_Collect_eq Sequ_assoc subsetI)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   115
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   116
lemma test:
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   117
  shows "(\<Union>x\<le>Suc n. Der c (A \<up> x)) = (\<Union>x\<le>n. Der c A ;; A \<up> x)"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   118
apply(induct n)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   119
apply(simp)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   120
apply(auto)[1]
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   121
apply(case_tac xa)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   122
apply(simp)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   123
apply(simp)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   124
apply(auto)[1]
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   125
apply(case_tac "[] \<in> A")
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   126
apply(simp)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   127
apply(simp)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   128
by (smt Der_Pow Der_Pow_subseteq UN_insert atMost_Suc sup.orderE sup_bot.right_neutral)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   129
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   130
lemma test2:
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   131
  shows "(\<Union>x\<in>(Suc ` A). Der c (B \<up> x)) = (\<Union>x\<in>A. Der c B ;; B \<up> x)"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   132
apply(auto)[1]
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   133
apply(case_tac "[] \<in> B")
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   134
apply(simp)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   135
using Der_Pow_subseteq apply blast
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   136
apply(simp)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   137
done
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   138
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   139
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
   140
section {* Kleene Star for Languages *}
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   142
definition 
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   143
  Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102) where
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   144
  "A\<star> = (\<Union>n. A \<up> n)"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   145
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   146
lemma Star_empty [intro]:
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   147
  shows "[] \<in> A\<star>"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   148
unfolding Star_def
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   149
by auto
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   150
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   151
lemma Star_step [intro]:
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   152
  assumes "s1 \<in> A" "s2 \<in> A\<star>"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   153
  shows "s1 @ s2 \<in> A\<star>"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   154
proof -
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   155
  from assms obtain n where "s1 \<in>A" "s2 \<in> A \<up> n"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   156
  unfolding Star_def by auto
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   157
  then have "s1 @ s2 \<in> A ;; (A \<up> n)"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   158
  by (auto simp add: Sequ_def)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   159
  then have "s1 @ s2 \<in> A \<up> (Suc n)"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   160
  by simp
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   161
  then show "s1 @ s2 \<in> A\<star>" 
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   162
  unfolding Star_def 
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   163
  by (auto simp del: Pow.simps)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   164
qed
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   165
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   166
lemma star_cases:
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   167
  shows "A\<star> = {[]} \<union> A ;; A\<star>"
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   168
unfolding Star_def
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   169
apply(simp add: Sequ_def)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   170
apply(auto)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   171
apply(case_tac xa)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   172
apply(auto simp add: Sequ_def)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   173
apply(rule_tac x="Suc xa" in exI)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   174
apply(auto simp add: Sequ_def)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   175
done
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   176
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   177
lemma Der_Star1:
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   178
  shows "Der c (A ;; A\<star>) = (Der c A) ;; A\<star>"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   179
proof -
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   180
  have "(Der c A) ;; A\<star> = (Der c A) ;; (\<Union>n. A \<up> n)"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   181
  unfolding Star_def by simp
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   182
  also have "... = (\<Union>n. Der c A ;; A \<up> n)"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   183
  unfolding Sequ_UNION by simp
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   184
  also have "... = (\<Union>x\<in>(Suc ` UNIV). Der c (A \<up> x))"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   185
  unfolding test2 by simp
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   186
  also have "... = (\<Union>n. Der c (A \<up> (Suc n)))"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   187
  by (simp)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   188
  also have "... = Der c (\<Union>n. A \<up> (Suc n))"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   189
  unfolding Der_UNION by simp
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   190
  also have "... = Der c (A ;; (\<Union>n. A \<up> n))"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   191
  by (simp only: Pow.simps Sequ_UNION)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   192
  finally show "Der c (A ;; A\<star>) = (Der c A) ;; A\<star>"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   193
  unfolding Star_def[symmetric] by blast 
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   194
qed
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   195
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   196
lemma Der_star [simp]:
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   197
  shows "Der c (A\<star>) = (Der c A) ;; A\<star>"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   198
proof -    
113
90fe1a1d7d0e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 112
diff changeset
   199
  have "Der c (A\<star>) = Der c ({[]} \<union> A ;; A\<star>)"  
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   200
    by (simp only: star_cases[symmetric])
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   201
  also have "... = Der c (A ;; A\<star>)"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   202
    by (simp only: Der_union Der_empty) (simp)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   203
  also have "... =  (Der c A) ;; A\<star>"
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   204
    using Der_Star1 by simp
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   205
  finally show "Der c (A\<star>) = (Der c A) ;; A\<star>" .
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   206
qed
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   207
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   208
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   209
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   210
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   211
section {* Regular Expressions *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   212
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   213
datatype rexp =
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   214
  ZERO
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   215
| ONE
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   216
| CHAR char
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   217
| SEQ rexp rexp
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   218
| ALT rexp rexp
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   219
| STAR rexp
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   220
| UPNTIMES rexp nat
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   221
| NTIMES rexp nat
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   222
| FROMNTIMES rexp nat
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   223
| NMTIMES rexp nat nat
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   224
| PLUS rexp
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   225
| AND rexp rexp
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   226
| NOT rexp
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   227
| ALLL
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   228
| ALLBUT
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   229
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   230
section {* Semantics of Regular Expressions *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   231
 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   232
fun
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   233
  L :: "rexp \<Rightarrow> string set"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   234
where
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   235
  "L (ZERO) = {}"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   236
| "L (ONE) = {[]}"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   237
| "L (CHAR c) = {[c]}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   238
| "L (SEQ r1 r2) = (L r1) ;; (L r2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   239
| "L (ALT r1 r2) = (L r1) \<union> (L r2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   240
| "L (STAR r) = (L r)\<star>"
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   241
| "L (UPNTIMES r n) = (\<Union>i\<in> {..n} . (L r) \<up> i)"
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   242
| "L (NTIMES r n) = (L r) \<up> n"
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   243
| "L (FROMNTIMES r n) = (\<Union>i\<in> {n..} . (L r) \<up> i)"
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   244
| "L (NMTIMES r n m) = (\<Union>i\<in>{n..m} . (L r) \<up> i)" 
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   245
| "L (PLUS r) = (\<Union>i\<in> {1..} . (L r) \<up> i)"
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   246
| "L (AND r1 r2) = (L r1) \<inter> (L r2)"
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   247
| "L (NOT r) = UNIV - (L r)"
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   248
| "L (ALLL) = UNIV"
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   249
| "L (ALLBUT) = UNIV - {[]}"
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   250
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   251
section {* Nullable, Derivatives *}
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   252
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   253
fun
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   254
 nullable :: "rexp \<Rightarrow> bool"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   255
where
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   256
  "nullable (ZERO) = False"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   257
| "nullable (ONE) = True"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   258
| "nullable (CHAR c) = False"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   259
| "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
| "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)"
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   261
| "nullable (STAR r) = True"
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   262
| "nullable (UPNTIMES r n) = True"
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   263
| "nullable (NTIMES r n) = (if n = 0 then True else nullable r)"
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   264
| "nullable (FROMNTIMES r n) = (if n = 0 then True else nullable r)"
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   265
| "nullable (NMTIMES r n m) = (if m < n then False else (if n = 0 then True else nullable r))"
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   266
| "nullable (PLUS r) = (nullable r)"
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   267
| "nullable (AND r1 r2) = (nullable r1 \<and> nullable r2)"
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   268
| "nullable (NOT r) = (\<not>nullable r)"
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   269
| "nullable (ALLL) = True"
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   270
| "nullable (ALLBUT) = False"
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   271
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   272
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   273
fun
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   274
 der :: "char \<Rightarrow> rexp \<Rightarrow> rexp"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   275
where
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   276
  "der c (ZERO) = ZERO"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   277
| "der c (ONE) = ZERO"
111
289728193164 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 110
diff changeset
   278
| "der c (CHAR d) = (if c = d then ONE else ZERO)"
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   279
| "der c (ALT r1 r2) = ALT (der c r1) (der c r2)"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   280
| "der c (SEQ r1 r2) = 
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   281
     (if nullable r1
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   282
      then ALT (SEQ (der c r1) r2) (der c r2)
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   283
      else SEQ (der c r1) r2)"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   284
| "der c (STAR r) = SEQ (der c r) (STAR r)"
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   285
| "der c (UPNTIMES r 0) = ZERO"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   286
| "der c (UPNTIMES r (Suc n)) = SEQ (der c r) (UPNTIMES r n)"
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   287
| "der c (NTIMES r 0) = ZERO"
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   288
| "der c (NTIMES r (Suc n)) = SEQ (der c r) (NTIMES r n)"
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
   289
| "der c (FROMNTIMES r 0) = SEQ (der c r) (FROMNTIMES r 0)"
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   290
| "der c (FROMNTIMES r (Suc n)) = SEQ (der c r) (FROMNTIMES r n)"
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   291
| "der c (NMTIMES r n m) = 
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   292
     (if m < n then ZERO 
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   293
      else (if n = 0 then (if m = 0 then ZERO else 
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   294
                           SEQ (der c r) (UPNTIMES r (m - 1))) else 
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   295
                           SEQ (der c r) (NMTIMES r (n - 1) (m - 1))))" 
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   296
| "der c (PLUS r) = SEQ (der c r) (STAR r)"
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   297
| "der c (AND r1 r2) = AND (der c r1) (der c r2)"
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   298
| "der c (NOT r) = NOT (der c r)"
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   299
| "der c (ALLL) = ALLL"
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   300
| "der c (ALLBUT) = ALLL"
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   301
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   302
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   303
fun 
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   304
 ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   305
where
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   306
  "ders [] r = r"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   307
| "ders (c # s) r = ders s (der c r)"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   308
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   309
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   310
lemma nullable_correctness:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   311
  shows "nullable r  \<longleftrightarrow> [] \<in> (L r)"
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   312
apply(induct r) 
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   313
apply(auto simp add: Sequ_def) 
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   314
done
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   315
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   316
lemma Der_Pow_notin:
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   317
  assumes "[] \<notin> A"
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   318
  shows "Der c (A \<up> (Suc n)) = (Der c A) ;; (A \<up> n)"
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   319
using assms
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   320
by(simp)
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   321
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   322
lemma der_correctness:
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   323
  shows "L (der c r) = Der c (L r)"
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   324
apply(induct c r rule: der.induct) 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   325
apply(simp_all add: nullable_correctness)[7]
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   326
apply(simp only: der.simps L.simps)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   327
apply(simp only: Der_UNION)
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   328
apply(simp only: Sequ_UNION[symmetric])
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   329
apply(simp add: test)
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   330
apply(simp)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   331
(* NTIMES *)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   332
apply(simp only: L.simps der.simps)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   333
apply(simp)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   334
apply(rule impI)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   335
apply (simp add: Der_Pow_subseteq sup_absorb1)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   336
(* FROMNTIMES *)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   337
apply(simp only: der.simps)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   338
apply(simp only: L.simps)
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
   339
apply(simp)
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   340
using Der_star Star_def apply auto[1]
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   341
apply(simp only: der.simps)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   342
apply(simp only: L.simps)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   343
apply(simp add: Der_UNION)
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   344
apply(subst Sequ_UNION[symmetric])
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   345
apply(subst test2[symmetric])
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   346
apply(subgoal_tac "(Suc ` {n..}) = {Suc n..}")
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   347
apply simp
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   348
apply(auto simp add: image_def)[1]
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   349
using Suc_le_D apply blast
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   350
(* NMTIMES *)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   351
apply(case_tac "n \<le> m")
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   352
prefer 2
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   353
apply(simp only: der.simps if_True)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   354
apply(simp only: L.simps)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   355
apply(simp)
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   356
apply(auto)[3]
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   357
apply(subst (asm) Sequ_UNION[symmetric])
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   358
apply(subst (asm) test[symmetric])
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   359
apply(auto simp add: Der_UNION)[1]
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   360
apply(auto simp add: Der_UNION)[1]
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   361
apply(subst Sequ_UNION[symmetric])
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   362
apply(subst test[symmetric])
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   363
apply(auto)[1]
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   364
apply(subst (asm) Sequ_UNION[symmetric])
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   365
apply(subst (asm) test2[symmetric])
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   366
apply(auto simp add: Der_UNION)[1]
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   367
apply(subst Sequ_UNION[symmetric])
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   368
apply(subst test2[symmetric])
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   369
apply(auto simp add: Der_UNION)[1]
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   370
(* PLUS *)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   371
apply(auto simp add: Sequ_def Star_def)[1]
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   372
apply(simp add: Der_UNION)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   373
apply(rule_tac x="Suc xa" in bexI)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   374
apply(auto simp add: Sequ_def Der_def)[2]
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   375
apply (metis append_Cons)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   376
apply(simp add: Der_UNION)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   377
apply(erule_tac bexE)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   378
apply(case_tac xa)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   379
apply(simp)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   380
apply(simp)
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   381
apply(auto)[1]
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   382
apply(auto simp add: Sequ_def Der_def)[1]
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   383
using Star_def apply auto[1]
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   384
apply(case_tac "[] \<in> L r")
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   385
apply(auto)[1]
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   386
using Der_UNION Der_star Star_def apply fastforce
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   387
apply(simp)
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   388
apply(simp)
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   389
apply(simp add: Der_def)
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   390
apply(blast)
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   391
(* ALLL*)
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   392
apply(simp add: Der_def)
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   393
apply(simp add: Der_def)
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   394
done
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   395
204
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   396
lemma ders_correctness:
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   397
  shows "L (ders s r) = Ders s (L r)"
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   398
apply(induct s arbitrary: r)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   399
apply(simp_all add: Ders_def der_correctness Der_def)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   400
done
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   401
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   402
lemma ders_ZERO:
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   403
  shows "ders s (ZERO) = ZERO"
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   404
apply(induct s)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   405
apply(simp_all)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   406
done
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   407
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   408
lemma ders_ONE:
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   409
  shows "ders s (ONE) = (if s = [] then ONE else ZERO)"
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   410
apply(induct s)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   411
apply(simp_all add: ders_ZERO)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   412
done
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   413
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   414
lemma ders_CHAR:
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   415
  shows "ders s (CHAR c) = (if s = [c] then ONE else 
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   416
                           (if s = [] then (CHAR c) else ZERO))"
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   417
apply(induct s)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   418
apply(simp_all add: ders_ZERO ders_ONE)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   419
done
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   420
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   421
lemma  ders_ALT:
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   422
  shows "ders s (ALT r1 r2) = ALT (ders s r1) (ders s r2)"
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   423
apply(induct s arbitrary: r1 r2)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   424
apply(simp_all)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   425
done
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   426
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   427
section {* Values *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   428
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   429
datatype val = 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   430
  Void
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   431
| Char char
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   432
| Seq val val
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   433
| Right val
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   434
| Left val
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   435
| Stars "val list"
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   436
| And val val
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   437
| Not val
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   438
| Alll
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   439
| Allbut
108
73f7dc60c285 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 107
diff changeset
   440
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   441
section {* The string behind a value *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   442
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   443
fun 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   444
  flat :: "val \<Rightarrow> string"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   445
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   446
  "flat (Void) = []"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   447
| "flat (Char c) = [c]"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   448
| "flat (Left v) = flat v"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   449
| "flat (Right v) = flat v"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   450
| "flat (Seq v1 v2) = (flat v1) @ (flat v2)"
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   451
| "flat (Stars []) = []"
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   452
| "flat (Stars (v#vs)) = (flat v) @ (flat (Stars vs))" 
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   453
| "flat (And v1 v2) = flat v1"
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   454
| "flat (Not v) = flat v"
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   455
| "flat Allbut = []"
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   456
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   457
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
   458
lemma flat_Stars [simp]:
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   459
 "flat (Stars vs) = concat (map flat vs)"
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
   460
by (induct vs) (auto)
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
   461
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   462
lemma Star_Pow:
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   463
  assumes "s \<in> A \<up> n"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   464
  shows "\<exists>ss. concat ss = s \<and> (\<forall>s \<in> set ss. s \<in> A) \<and> (length ss = n)"
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   465
using assms
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   466
apply(induct n arbitrary: s)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   467
apply(auto simp add: Sequ_def)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   468
apply(drule_tac x="s2" in meta_spec)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   469
apply(auto)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   470
apply(rule_tac x="s1#ss" in exI)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   471
apply(simp)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   472
done
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   473
90
3c8cfdf95252 proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 89
diff changeset
   474
lemma Star_string:
3c8cfdf95252 proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 89
diff changeset
   475
  assumes "s \<in> A\<star>"
3c8cfdf95252 proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 89
diff changeset
   476
  shows "\<exists>ss. concat ss = s \<and> (\<forall>s \<in> set ss. s \<in> A)"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   477
using assms
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   478
apply(auto simp add: Star_def)
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   479
using Star_Pow by blast
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   480
90
3c8cfdf95252 proved some lemmas about star and mkeps (injval etc not yet done)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 89
diff changeset
   481
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   482
section {* Sulzmann and Lu functions *}
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   483
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   484
fun 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   485
  mkeps :: "rexp \<Rightarrow> val"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   486
where
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   487
  "mkeps(ONE) = Void"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   488
| "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)"
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   489
| "mkeps(ALT r1 r2) = (if nullable r1 then Left (mkeps r1) else Right (mkeps r2))"
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   490
| "mkeps(STAR r) = Stars []"
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   491
| "mkeps(UPNTIMES r n) = Stars []"
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   492
| "mkeps(NTIMES r n) = Stars (replicate n (mkeps r))"
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   493
| "mkeps(FROMNTIMES r n) = Stars (replicate n (mkeps r))"
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   494
| "mkeps(NMTIMES r n m) = Stars (replicate n (mkeps r))"
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   495
| "mkeps(PLUS r) = Stars ([mkeps r])"
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   496
| "mkeps(AND r1 r2) = And (mkeps r1) (mkeps r2)"
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   497
| "mkeps(NOT r) = Not (Allbut)"
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   498
| "mkeps(ALLL) = Void"
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   499
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   500
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   501
fun injval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   502
where
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   503
  "injval (CHAR d) c Void = Char d"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   504
| "injval (ALT r1 r2) c (Left v1) = Left(injval r1 c v1)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   505
| "injval (ALT r1 r2) c (Right v2) = Right(injval r2 c v2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   506
| "injval (SEQ r1 r2) c (Seq v1 v2) = Seq (injval r1 c v1) v2"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   507
| "injval (SEQ r1 r2) c (Left (Seq v1 v2)) = Seq (injval r1 c v1) v2"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   508
| "injval (SEQ r1 r2) c (Right v2) = Seq (mkeps r1) (injval r2 c v2)"
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   509
| "injval (STAR r) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" 
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   510
| "injval (UPNTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)"
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   511
| "injval (NTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)"
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   512
| "injval (FROMNTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)"
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   513
| "injval (NMTIMES r n m) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)"
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   514
| "injval (PLUS r) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)"
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   515
| "injval (AND r1 r2) c (And v1 v2) = And (injval r1 c v1) (injval r2 c v2)"
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   516
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   517
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   518
section {* Mkeps, injval *}
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   519
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   520
lemma mkeps_flat:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   521
  assumes "nullable(r)" 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   522
  shows "flat (mkeps r) = []"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   523
using assms
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   524
apply (induct r) 
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   525
apply(auto)[15]
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   526
apply(case_tac "x3a < x2")
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   527
apply(auto)[2]
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   528
done
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   529
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   530
lemma Prf_injval_flat:
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   531
  assumes "flat v \<in> L (der c r)" 
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   532
  shows "flat (injval r c v) = c # (flat v)"
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   533
using assms
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   534
apply(induct arbitrary: v rule: der.induct)
239
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   535
apply(simp_all)
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   536
apply(case_tac "c = d")
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   537
prefer 2
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   538
apply(simp)
e59cec211f4f added automata implementation
Christian Urban <urbanc@in.tum.de>
parents: 238
diff changeset
   539
apply(simp)
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   540
apply(auto elim!: Prf_elims split: if_splits)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   541
apply(metis mkeps_flat)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   542
apply(rotate_tac 2)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   543
apply(erule Prf.cases)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   544
apply(simp_all)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   545
apply(rotate_tac 2)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   546
apply(erule Prf.cases)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   547
apply(simp_all)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   548
apply(rotate_tac 2)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   549
apply(erule Prf.cases)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   550
apply(simp_all)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   551
apply(rotate_tac 2)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   552
apply(erule Prf.cases)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   553
apply(simp_all)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   554
apply(rotate_tac 2)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   555
apply(erule Prf.cases)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   556
apply(simp_all)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   557
apply(rotate_tac 3)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   558
apply(erule Prf.cases)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   559
apply(simp_all)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   560
apply(rotate_tac 4)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   561
apply(erule Prf.cases)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   562
apply(simp_all)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   563
apply(rotate_tac 2)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   564
apply(erule Prf.cases)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   565
apply(simp_all)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   566
apply(rotate_tac 2)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   567
apply(erule Prf.cases)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   568
apply(simp_all)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   569
done
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   570
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   571
lemma Prf_injval:
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   572
  assumes "\<turnstile> v : der c r" 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   573
  shows "\<turnstile> (injval r c v) : r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   574
using assms
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   575
apply(induct r arbitrary: c v rule: rexp.induct)
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   576
apply(auto intro!: Prf.intros mkeps_nullable elim!: Prf_elims split: if_splits)
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   577
(* STAR *)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   578
apply(rotate_tac 2)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   579
apply(erule Prf.cases)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   580
apply(simp_all)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   581
apply(auto)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   582
using Prf.intros(6) apply auto[1]
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   583
(* UPNTIMES *)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   584
apply(case_tac x2)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   585
apply(simp)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   586
using Prf_elims(1) apply auto[1]
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   587
apply(simp)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   588
apply(erule Prf.cases)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   589
apply(simp_all)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   590
apply(clarify)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   591
apply(rotate_tac 2)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   592
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   593
apply(simp_all)
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   594
apply(clarify)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   595
using Prf.intros(7) apply auto[1]
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   596
(* NTIMES *)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   597
apply(case_tac x2)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   598
apply(simp)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   599
using Prf_elims(1) apply auto[1]
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   600
apply(simp)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   601
apply(erule Prf.cases)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   602
apply(simp_all)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   603
apply(clarify)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   604
apply(rotate_tac 2)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   605
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   606
apply(simp_all)
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   607
apply(clarify)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   608
using Prf.intros(8) apply auto[1]
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   609
(* FROMNTIMES *)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   610
apply(case_tac x2)
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   611
apply(simp)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   612
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   613
apply(simp_all)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   614
apply(clarify)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   615
apply(rotate_tac 2)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   616
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   617
apply(simp_all)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   618
apply(clarify)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   619
using Prf.intros(9) apply auto[1]
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   620
apply(rotate_tac 1)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   621
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   622
apply(simp_all)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   623
apply(clarify)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   624
apply(rotate_tac 2)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   625
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   626
apply(simp_all)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   627
apply(clarify)
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   628
using Prf.intros(9) apply auto
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   629
(* NMTIMES *)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   630
apply(rotate_tac 3)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   631
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   632
apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   633
apply(clarify)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   634
apply(rule Prf.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   635
apply(auto)[2]
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   636
apply simp
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   637
apply(rotate_tac 4)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   638
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   639
apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   640
apply(clarify)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   641
apply(rule Prf.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   642
apply(auto)[2]
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   643
apply simp
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   644
(* PLUS *)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   645
apply(rotate_tac 2)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   646
apply(erule Prf.cases)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   647
apply(simp_all)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   648
apply(auto)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   649
using Prf.intros apply auto[1]
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   650
(* AND *)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   651
apply(erule Prf.cases)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   652
apply(simp_all)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   653
apply(auto)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   654
apply(rule Prf.intros)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   655
apply(simp)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   656
apply(simp)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   657
apply(simp add: Prf_injval_flat)
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   658
done
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   659
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   660
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   661
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   662
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   663
104
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   664
section {* Our Alternative Posix definition *}
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   665
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   666
inductive 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   667
  Posix :: "string \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<in> _ \<rightarrow> _" [100, 100, 100] 100)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   668
where
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   669
  Posix_ONE: "[] \<in> ONE \<rightarrow> Void"
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   670
| Posix_CHAR: "[c] \<in> (CHAR c) \<rightarrow> (Char c)"
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   671
| Posix_ALT1: "s \<in> r1 \<rightarrow> v \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Left v)"
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   672
| Posix_ALT2: "\<lbrakk>s \<in> r2 \<rightarrow> v; s \<notin> L(r1)\<rbrakk> \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Right v)"
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   673
| Posix_SEQ: "\<lbrakk>s1 \<in> r1 \<rightarrow> v1; s2 \<in> r2 \<rightarrow> v2;
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   674
    \<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> 
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   675
    (s1 @ s2) \<in> (SEQ r1 r2) \<rightarrow> (Seq v1 v2)"
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   676
| Posix_STAR1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> STAR r \<rightarrow> Stars vs; flat v \<noteq> [];
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   677
    \<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>
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   678
    \<Longrightarrow> (s1 @ s2) \<in> STAR r \<rightarrow> Stars (v # vs)"
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   679
| Posix_STAR2: "[] \<in> STAR r \<rightarrow> Stars []"
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   680
| Posix_UPNTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> UPNTIMES r n \<rightarrow> Stars vs; flat v \<noteq> [];
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   681
    \<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))\<rbrakk>
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   682
    \<Longrightarrow> (s1 @ s2) \<in> UPNTIMES r (Suc n) \<rightarrow> Stars (v # vs)"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   683
| Posix_UPNTIMES2: "[] \<in> UPNTIMES r n \<rightarrow> Stars []"
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
   684
| Posix_NTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> NTIMES r n \<rightarrow> Stars vs; flat v = [] \<Longrightarrow> flat (Stars vs) = [];
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   685
    \<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))\<rbrakk>
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   686
    \<Longrightarrow> (s1 @ s2) \<in> NTIMES r (Suc n) \<rightarrow> Stars (v # vs)"
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   687
| Posix_NTIMES2: "[] \<in> NTIMES r 0 \<rightarrow> Stars []"
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
   688
| Posix_FROMNTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> FROMNTIMES r n \<rightarrow> Stars vs; flat v = [] \<Longrightarrow> flat (Stars vs) = [];
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   689
    \<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))\<rbrakk>
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   690
    \<Longrightarrow> (s1 @ s2) \<in> FROMNTIMES r (Suc n) \<rightarrow> Stars (v # vs)"
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
   691
| Posix_FROMNTIMES2: "s \<in> STAR r \<rightarrow> Stars vs \<Longrightarrow>  s \<in> FROMNTIMES r 0 \<rightarrow> Stars vs"
234
18d19d039ac9 updated
Christian Urban <urbanc@in.tum.de>
parents: 233
diff changeset
   692
| Posix_NMTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> NMTIMES r n m \<rightarrow> Stars vs; flat v = [] \<Longrightarrow> flat (Stars vs) = [];
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   693
    \<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 m))\<rbrakk>
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   694
    \<Longrightarrow> (s1 @ s2) \<in> NMTIMES r (Suc n) (Suc m) \<rightarrow> Stars (v # vs)"
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   695
| Posix_NMTIMES2: "s \<in> UPNTIMES r m \<rightarrow> Stars vs \<Longrightarrow>  s \<in> NMTIMES r 0 m \<rightarrow> Stars vs"
233
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   696
| Posix_PLUS1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> STAR r \<rightarrow> Stars vs; flat v = [] \<Longrightarrow> flat (Stars vs) = [];
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   697
    \<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>
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   698
    \<Longrightarrow> (s1 @ s2) \<in> PLUS r \<rightarrow> Stars (v # vs)"
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   699
| Posix_AND: "\<lbrakk>s \<in> r1 \<rightarrow> v1; s \<in> r2 \<rightarrow> v2\<rbrakk> \<Longrightarrow> s \<in> (AND r1 r2) \<rightarrow> (And v1 v2)"
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
   700
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   701
inductive_cases Posix_elims:
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   702
  "s \<in> ZERO \<rightarrow> v"
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   703
  "s \<in> ONE \<rightarrow> v"
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   704
  "s \<in> CHAR c \<rightarrow> v"
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   705
  "s \<in> ALT r1 r2 \<rightarrow> v"
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   706
  "s \<in> SEQ r1 r2 \<rightarrow> v"
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   707
  "s \<in> STAR r \<rightarrow> v"
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   708
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   709
lemma Posix1:
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   710
  assumes "s \<in> r \<rightarrow> v"
123
1bee7006b92b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
   711
  shows "s \<in> L r" "flat v = s"
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   712
using assms
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   713
apply (induct s r v rule: Posix.induct)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   714
apply(auto simp add: Sequ_def)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   715
apply(rule_tac x="Suc x" in bexI)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   716
apply(auto simp add: Sequ_def)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   717
apply(rule_tac x="Suc x" in bexI)
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   718
using Sequ_def apply auto[2]
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
   719
apply(simp add: Star_def)
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   720
apply(rule_tac x="Suc x" in bexI)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   721
apply(auto simp add: Sequ_def)
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   722
apply(simp add: Star_def)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   723
apply(clarify)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   724
apply(rule_tac x="Suc x" in bexI)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   725
apply(auto simp add: Sequ_def)
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   726
done
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   727
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   728
233
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   729
lemma 
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   730
  "([] @ []) \<in> PLUS (ONE) \<rightarrow> Stars ([Void])"
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   731
apply(rule Posix_PLUS1)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   732
apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   733
apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   734
apply(simp)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   735
apply(simp)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   736
done
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   737
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   738
lemma 
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   739
  assumes "s \<in> r \<rightarrow> v" "flat v \<noteq> []" "\<forall>s' \<in> L r. length s' < length s"
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   740
  shows "([] @ (s @ [])) \<in> PLUS (ALT ONE r) \<rightarrow> Stars ([Left Void, Right v])"
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   741
using assms
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   742
oops
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   743
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   744
lemma 
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   745
  "([] @ ([] @ [])) \<in> FROMNTIMES (ONE) (Suc (Suc 0)) \<rightarrow> Stars ([Void, Void])"
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   746
apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   747
apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   748
apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   749
apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   750
apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   751
apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   752
apply(auto)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   753
done
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   754
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   755
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   756
lemma 
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   757
  assumes "s \<in> r \<rightarrow> v" "flat v \<noteq> []"
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   758
  "s \<in> PLUS (ALT ONE r) \<rightarrow> Stars ([Left(Void), Right(v)])"
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   759
  shows "False"
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   760
using assms
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   761
apply(rotate_tac 2)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   762
apply(erule_tac Posix.cases)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   763
apply(simp_all)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   764
apply(auto)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   765
oops
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   766
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   767
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   768
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   769
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
   770
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   771
lemma Posix1a:
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   772
  assumes "s \<in> r \<rightarrow> v"
123
1bee7006b92b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
   773
  shows "\<turnstile> v : r"
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   774
using assms
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   775
apply(induct s r v rule: Posix.induct)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
   776
apply(auto intro: Prf.intros)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   777
apply(rule Prf.intros)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   778
apply(auto)[1]
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   779
apply(rotate_tac 3)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   780
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   781
apply(simp_all)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   782
apply(rule Prf.intros)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   783
apply(auto)[1]
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   784
apply(rotate_tac 3)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   785
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   786
apply(simp_all)
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   787
apply(rotate_tac 3)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   788
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   789
apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   790
apply(rule Prf.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   791
apply(auto)[1]
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   792
apply(rotate_tac 3)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   793
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   794
apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   795
apply(rotate_tac 3)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   796
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   797
apply(simp_all)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   798
apply(rule Prf.intros)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   799
apply(auto)[1]
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   800
apply(rotate_tac 3)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   801
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   802
apply(simp_all)
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   803
apply(rotate_tac 3)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   804
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   805
apply(simp_all)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   806
apply(rule Prf.intros)
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   807
apply(auto)[2]
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   808
apply(rotate_tac 3)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   809
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   810
apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   811
apply(rule Prf.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   812
apply(auto)[3]
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   813
apply(rotate_tac 3)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   814
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   815
apply(simp_all)
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   816
apply(rotate_tac 3)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   817
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   818
apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   819
apply(rotate_tac 3)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   820
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   821
apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   822
apply(rule Prf.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   823
apply(auto)[3]
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   824
apply(rotate_tac 3)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   825
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   826
apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   827
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   828
apply(simp_all)
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   829
apply(rotate_tac 3)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   830
apply(erule Prf.cases)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   831
apply(simp_all)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   832
apply(rule Prf.intros)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   833
apply(auto)
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   834
apply(rule Prf.intros)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   835
apply(auto)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
   836
by (simp add: Posix1(2))
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   837
222
4c02878e2fe0 added two sanity lemmas
Christian Urban <urbanc@in.tum.de>
parents: 221
diff changeset
   838
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   839
lemma  Posix_NTIMES_mkeps:
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   840
  assumes "[] \<in> r \<rightarrow> mkeps r"
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   841
  shows "[] \<in> NTIMES r n \<rightarrow> Stars (replicate n (mkeps r))"
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   842
apply(induct n)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   843
apply(simp)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   844
apply (rule Posix_NTIMES2)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   845
apply(simp)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   846
apply(subst append_Nil[symmetric])
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   847
apply (rule Posix_NTIMES1)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   848
apply(auto)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   849
apply(rule assms)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   850
done
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   851
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   852
lemma  Posix_FROMNTIMES_mkeps:
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   853
  assumes "[] \<in> r \<rightarrow> mkeps r"
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   854
  shows "[] \<in> FROMNTIMES r n \<rightarrow> Stars (replicate n (mkeps r))"
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   855
apply(induct n)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   856
apply(simp)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   857
apply (rule Posix_FROMNTIMES2)
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
   858
apply (rule Posix.intros)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   859
apply(simp)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   860
apply(subst append_Nil[symmetric])
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   861
apply (rule Posix_FROMNTIMES1)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   862
apply(auto)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   863
apply(rule assms)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   864
done
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   865
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   866
lemma  Posix_NMTIMES_mkeps:
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   867
  assumes "[] \<in> r \<rightarrow> mkeps r" "n \<le> m"
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   868
  shows "[] \<in> NMTIMES r n m \<rightarrow> Stars (replicate n (mkeps r))"
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   869
using assms(2)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   870
apply(induct n arbitrary: m)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   871
apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   872
apply(rule Posix.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   873
apply(rule Posix.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   874
apply(case_tac m)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   875
apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   876
apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   877
apply(subst append_Nil[symmetric])
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   878
apply(rule Posix.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   879
apply(auto)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   880
apply(rule assms)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   881
done
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   882
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   883
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   884
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   885
lemma Posix_mkeps:
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   886
  assumes "nullable r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   887
  shows "[] \<in> r \<rightarrow> mkeps r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   888
using assms
185
841f7b9c0a6a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 172
diff changeset
   889
apply(induct r rule: nullable.induct)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   890
apply(auto intro: Posix.intros simp add: nullable_correctness Sequ_def)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   891
apply(subst append.simps(1)[symmetric])
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   892
apply(rule Posix.intros)
123
1bee7006b92b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
   893
apply(auto)
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   894
apply(case_tac n)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   895
apply(simp)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   896
apply (simp add: Posix_NTIMES2)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   897
apply(simp)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   898
apply(subst append.simps(1)[symmetric])
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   899
apply(rule Posix.intros)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   900
apply(auto)
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   901
apply(rule Posix_NTIMES_mkeps)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
   902
apply(simp)
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
   903
apply(rule Posix.intros)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
   904
apply(rule Posix.intros)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   905
apply(case_tac n)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   906
apply(simp)
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
   907
apply(rule Posix.intros)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
   908
apply(rule Posix.intros)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   909
apply(simp)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   910
apply(subst append.simps(1)[symmetric])
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   911
apply(rule Posix.intros)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   912
apply(auto)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   913
apply(rule Posix_FROMNTIMES_mkeps)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
   914
apply(simp)
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   915
apply(rule Posix.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   916
apply(rule Posix.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   917
apply(case_tac n)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   918
apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   919
apply(rule Posix.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   920
apply(rule Posix.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   921
apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   922
apply(case_tac m)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   923
apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   924
apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   925
apply(subst append_Nil[symmetric])
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   926
apply(rule Posix.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   927
apply(auto)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   928
apply(rule Posix_NMTIMES_mkeps)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
   929
apply(auto)
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   930
apply(subst append_Nil[symmetric])
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   931
apply(rule Posix.intros)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   932
apply(auto)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
   933
apply(rule Posix.intros)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   934
done
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   935
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   936
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   937
lemma Posix_determ:
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   938
  assumes "s \<in> r \<rightarrow> v1" "s \<in> r \<rightarrow> v2"
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   939
  shows "v1 = v2"
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   940
using assms
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   941
proof (induct s r v1 arbitrary: v2 rule: Posix.induct)
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   942
  case (Posix_ONE v2)
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   943
  have "[] \<in> ONE \<rightarrow> v2" by fact
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   944
  then show "Void = v2" by cases auto
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   945
next 
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   946
  case (Posix_CHAR c v2)
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   947
  have "[c] \<in> CHAR c \<rightarrow> v2" by fact
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   948
  then show "Char c = v2" by cases auto
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   949
next 
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   950
  case (Posix_ALT1 s r1 v r2 v2)
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   951
  have "s \<in> ALT r1 r2 \<rightarrow> v2" by fact
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   952
  moreover
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   953
  have "s \<in> r1 \<rightarrow> v" by fact
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   954
  then have "s \<in> L r1" by (simp add: Posix1)
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   955
  ultimately obtain v' where eq: "v2 = Left v'" "s \<in> r1 \<rightarrow> v'" by cases auto 
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   956
  moreover
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   957
  have IH: "\<And>v2. s \<in> r1 \<rightarrow> v2 \<Longrightarrow> v = v2" by fact
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   958
  ultimately have "v = v'" by simp
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   959
  then show "Left v = v2" using eq by simp
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   960
next 
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   961
  case (Posix_ALT2 s r2 v r1 v2)
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   962
  have "s \<in> ALT r1 r2 \<rightarrow> v2" by fact
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   963
  moreover
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   964
  have "s \<notin> L r1" by fact
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   965
  ultimately obtain v' where eq: "v2 = Right v'" "s \<in> r2 \<rightarrow> v'" 
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   966
    by cases (auto simp add: Posix1) 
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   967
  moreover
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   968
  have IH: "\<And>v2. s \<in> r2 \<rightarrow> v2 \<Longrightarrow> v = v2" by fact
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   969
  ultimately have "v = v'" by simp
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   970
  then show "Right v = v2" using eq by simp
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   971
next
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   972
  case (Posix_SEQ s1 r1 v1 s2 r2 v2 v')
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   973
  have "(s1 @ s2) \<in> SEQ r1 r2 \<rightarrow> v'" 
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   974
       "s1 \<in> r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2"
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   975
       "\<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+
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   976
  then obtain v1' v2' where "v' = Seq v1' v2'" "s1 \<in> r1 \<rightarrow> v1'" "s2 \<in> r2 \<rightarrow> v2'"
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   977
  apply(cases) apply (auto simp add: append_eq_append_conv2)
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   978
  using Posix1(1) by fastforce+
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   979
  moreover
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   980
  have IHs: "\<And>v1'. s1 \<in> r1 \<rightarrow> v1' \<Longrightarrow> v1 = v1'"
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   981
            "\<And>v2'. s2 \<in> r2 \<rightarrow> v2' \<Longrightarrow> v2 = v2'" by fact+
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   982
  ultimately show "Seq v1 v2 = v'" by simp
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   983
next
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   984
  case (Posix_STAR1 s1 r v s2 vs v2)
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   985
  have "(s1 @ s2) \<in> STAR r \<rightarrow> v2" 
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   986
       "s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" "flat v \<noteq> []"
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   987
       "\<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+
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   988
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (STAR r) \<rightarrow> (Stars vs')"
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   989
  apply(cases) apply (auto simp add: append_eq_append_conv2)
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   990
  using Posix1(1) apply fastforce
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   991
  apply (metis Posix1(1) Posix_STAR1.hyps(6) append_Nil append_Nil2)
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   992
  using Posix1(2) by blast
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   993
  moreover
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   994
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   995
            "\<And>v2. s2 \<in> STAR r \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   996
  ultimately show "Stars (v # vs) = v2" by auto
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   997
next
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   998
  case (Posix_STAR2 r v2)
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   999
  have "[] \<in> STAR r \<rightarrow> v2" by fact
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
  1000
  then show "Stars [] = v2" by cases (auto simp add: Posix1)
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1001
next
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1002
  case (Posix_UPNTIMES1 s1 r v s2 n vs v2)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1003
  have "(s1 @ s2) \<in> UPNTIMES r (Suc n) \<rightarrow> v2" 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1004
       "s1 \<in> r \<rightarrow> v" "s2 \<in> (UPNTIMES r n) \<rightarrow> Stars vs" "flat v \<noteq> []"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1005
       "\<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))" by fact+
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1006
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (UPNTIMES r n) \<rightarrow> (Stars vs')"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1007
  apply(cases) apply (auto simp add: append_eq_append_conv2)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1008
  using Posix1(1) apply fastforce
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1009
  apply (metis Posix1(1) Posix_UPNTIMES1.hyps(6) append_Nil append_Nil2)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1010
  using Posix1(2) by blast
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1011
  moreover
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1012
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1013
            "\<And>v2. s2 \<in> UPNTIMES r n \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1014
  ultimately show "Stars (v # vs) = v2" by auto
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1015
next
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1016
  case (Posix_UPNTIMES2 r n v2)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1017
  have "[] \<in> UPNTIMES r n \<rightarrow> v2" by fact
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1018
  then show "Stars [] = v2" by cases (auto simp add: Posix1)
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1019
next
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1020
  case (Posix_NTIMES2 r v2)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1021
  have "[] \<in> NTIMES r 0 \<rightarrow> v2" by fact
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1022
  then show "Stars [] = v2" by cases (auto simp add: Posix1)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1023
next
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1024
  case (Posix_NTIMES1 s1 r v s2 n vs v2)
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1025
  have "(s1 @ s2) \<in> NTIMES r (Suc n) \<rightarrow> v2"  "flat v = [] \<Longrightarrow> flat (Stars vs) = []"
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1026
       "s1 \<in> r \<rightarrow> v" "s2 \<in> (NTIMES r n) \<rightarrow> Stars vs"
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1027
       "\<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))" by fact+
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1028
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (NTIMES r n) \<rightarrow> (Stars vs')"
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1029
  apply(cases) apply (auto simp add: append_eq_append_conv2)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1030
  using Posix1(1) apply fastforce
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1031
  by (metis Posix1(1) Posix_NTIMES1.hyps(6) append_Nil append_Nil2)
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1032
  moreover
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1033
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1034
            "\<And>v2. s2 \<in> NTIMES r n \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1035
  ultimately show "Stars (v # vs) = v2" by auto
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1036
next
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1037
  case (Posix_FROMNTIMES2 s r v1 v2)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1038
  have "s \<in> FROMNTIMES r 0 \<rightarrow> v2" "s \<in> STAR r \<rightarrow> Stars v1" 
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1039
       "\<And>v3. s \<in> STAR r \<rightarrow> v3 \<Longrightarrow> Stars v1 = v3" by fact+
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1040
  then show ?case 
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1041
  apply(cases)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1042
  apply(auto)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1043
  done
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1044
next
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1045
  case (Posix_FROMNTIMES1 s1 r v s2 n vs v2)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1046
  have "(s1 @ s2) \<in> FROMNTIMES r (Suc n) \<rightarrow> v2" 
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1047
       "s1 \<in> r \<rightarrow> v" "s2 \<in> (FROMNTIMES r n) \<rightarrow> Stars vs" "flat v = [] \<Longrightarrow> flat (Stars vs) = []"
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1048
       "\<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))" by fact+
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1049
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (FROMNTIMES r n) \<rightarrow> (Stars vs')"
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1050
  apply(cases) apply (auto simp add: append_eq_append_conv2)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1051
  using Posix1(1) apply fastforce
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1052
  by (metis Posix1(1) Posix_FROMNTIMES1.hyps(6) append_Nil append_Nil2)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1053
  moreover
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1054
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1055
            "\<And>v2. s2 \<in> FROMNTIMES r n \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1056
  ultimately show "Stars (v # vs) = v2" by auto
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1057
next
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1058
  case (Posix_NMTIMES2 s r m v1 v2)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1059
  have "s \<in> NMTIMES r 0 m \<rightarrow> v2" "s \<in> UPNTIMES r m \<rightarrow> Stars v1" 
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1060
       "\<And>v3. s \<in> UPNTIMES r m \<rightarrow> v3 \<Longrightarrow> Stars v1 = v3" by fact+
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1061
  then show ?case 
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1062
  apply(cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1063
  apply(auto)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1064
  done
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1065
next
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1066
  case (Posix_NMTIMES1 s1 r v s2 n m vs v2)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1067
  have "(s1 @ s2) \<in> NMTIMES r (Suc n) (Suc m) \<rightarrow> v2" 
235
f476c98cad28 updated
Christian Urban <urbanc@in.tum.de>
parents: 234
diff changeset
  1068
       "s1 \<in> r \<rightarrow> v" "s2 \<in> (NMTIMES r n m) \<rightarrow> Stars vs" "flat v = [] \<Longrightarrow> flat (Stars vs) = []"
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1069
       "\<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 m))" by fact+
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1070
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (NMTIMES r n m) \<rightarrow> (Stars vs')"
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1071
  apply(cases) apply (auto simp add: append_eq_append_conv2)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1072
  using Posix1(1) apply fastforce
235
f476c98cad28 updated
Christian Urban <urbanc@in.tum.de>
parents: 234
diff changeset
  1073
  by (metis Posix1(1) Posix_NMTIMES1.hyps(6) self_append_conv self_append_conv2)
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1074
  moreover
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1075
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1076
            "\<And>v2. s2 \<in> NMTIMES r n m \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1077
  ultimately show "Stars (v # vs) = v2" by auto
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1078
next
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1079
  case (Posix_PLUS1 s1 r v s2 vs v2)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1080
  have "(s1 @ s2) \<in> PLUS r \<rightarrow> v2" 
233
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1081
       "s1 \<in> r \<rightarrow> v" "s2 \<in> (STAR r) \<rightarrow> Stars vs" (*"flat v = [] \<Longrightarrow> flat (Stars vs) = []"*)
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1082
       "\<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+
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1083
  then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (STAR r) \<rightarrow> (Stars vs')"
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1084
  apply(cases) apply (auto simp add: append_eq_append_conv2)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1085
  using Posix1(1) apply fastforce
233
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1086
  by (metis Posix1(1) Posix_PLUS1.hyps(6) append_self_conv append_self_conv2)
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1087
  moreover
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1088
  have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1089
            "\<And>v2. s2 \<in> STAR r \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1090
  ultimately show "Stars (v # vs) = v2" by auto
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1091
next 
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1092
  case (Posix_AND s r1 v1 r2 v2 v')
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1093
  have "s \<in> AND r1 r2 \<rightarrow> v'" 
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1094
       "s \<in> r1 \<rightarrow> v1" "s \<in> r2 \<rightarrow> v2" by fact+
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1095
  then obtain v1' v2' where "v' = And v1' v2'" "s \<in> r1 \<rightarrow> v1'" "s \<in> r2 \<rightarrow> v2'"
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1096
  apply(cases) apply (auto simp add: append_eq_append_conv2)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1097
  done
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1098
  moreover
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1099
  have IHs: "\<And>v1'. s \<in> r1 \<rightarrow> v1' \<Longrightarrow> v1 = v1'"
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1100
            "\<And>v2'. s \<in> r2 \<rightarrow> v2' \<Longrightarrow> v2 = v2'" by fact+
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1101
  ultimately show "And v1 v2 = v'" by simp
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
  1102
qed
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
  1103
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1104
lemma NTIMES_Stars:
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1105
 assumes "\<turnstile> v : NTIMES r n"
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1106
 shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> length vs = n"
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1107
using assms
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1108
apply(induct n arbitrary: v)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1109
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1110
apply(simp_all)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1111
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1112
apply(simp_all)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1113
done
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1114
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1115
lemma UPNTIMES_Stars:
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1116
 assumes "\<turnstile> v : UPNTIMES r n"
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1117
 shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> length vs \<le> n"
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1118
using assms
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1119
apply(induct n arbitrary: v)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1120
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1121
apply(simp_all)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1122
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1123
apply(simp_all)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1124
done
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1125
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1126
lemma FROMNTIMES_Stars:
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1127
 assumes "\<turnstile> v : FROMNTIMES r n"
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1128
 shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> n \<le> length vs"
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1129
using assms
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1130
apply(induct n arbitrary: v)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1131
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1132
apply(simp_all)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1133
apply(erule Prf.cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1134
apply(simp_all)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1135
done
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1136
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1137
lemma PLUS_Stars:
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1138
 assumes "\<turnstile> v : PLUS r"
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1139
 shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> 1 \<le> length vs"
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1140
using assms
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1141
apply(erule_tac Prf.cases)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1142
apply(simp_all)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1143
done
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1144
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1145
lemma NMTIMES_Stars:
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1146
 assumes "\<turnstile> v : NMTIMES r n m"
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1147
 shows "\<exists>vs. v = Stars vs \<and> (\<forall>v \<in> set vs. \<turnstile> v : r) \<and> n \<le> length vs \<and> length vs \<le> m"
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1148
using assms
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1149
apply(induct n arbitrary: m v)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1150
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1151
apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1152
apply(erule Prf.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1153
apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1154
done
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1155
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1156
172
cdc0bdcfba3f updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
  1157
lemma Posix_injval:
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
  1158
  assumes "s \<in> (der c r) \<rightarrow> v"
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
  1159
  shows "(c # s) \<in> r \<rightarrow> (injval r c v)"
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
  1160
using assms
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1161
proof(induct r arbitrary: s v rule: rexp.induct)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1162
  case ZERO
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1163
  have "s \<in> der c ZERO \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1164
  then have "s \<in> ZERO \<rightarrow> v" by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1165
  then have "False" by cases
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
  1166
  then show "(c # s) \<in> ZERO \<rightarrow> (injval ZERO c v)" by simp
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1167
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1168
  case ONE
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1169
  have "s \<in> der c ONE \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1170
  then have "s \<in> ZERO \<rightarrow> v" by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1171
  then have "False" by cases
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
  1172
  then show "(c # s) \<in> ONE \<rightarrow> (injval ONE c v)" by simp
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1173
next 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1174
  case (CHAR d)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1175
  consider (eq) "c = d" | (ineq) "c \<noteq> d" by blast
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
  1176
  then show "(c # s) \<in> (CHAR d) \<rightarrow> (injval (CHAR d) c v)"
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1177
  proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1178
    case eq
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1179
    have "s \<in> der c (CHAR d) \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1180
    then have "s \<in> ONE \<rightarrow> v" using eq by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1181
    then have eqs: "s = [] \<and> v = Void" by cases simp
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1182
    show "(c # s) \<in> CHAR d \<rightarrow> injval (CHAR d) c v" using eq eqs 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1183
    by (auto intro: Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1184
  next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1185
    case ineq
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1186
    have "s \<in> der c (CHAR d) \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1187
    then have "s \<in> ZERO \<rightarrow> v" using ineq by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1188
    then have "False" by cases
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1189
    then show "(c # s) \<in> CHAR d \<rightarrow> injval (CHAR d) c v" by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1190
  qed
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1191
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1192
  case (ALT r1 r2)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1193
  have IH1: "\<And>s v. s \<in> der c r1 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r1 \<rightarrow> injval r1 c v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1194
  have IH2: "\<And>s v. s \<in> der c r2 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r2 \<rightarrow> injval r2 c v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1195
  have "s \<in> der c (ALT r1 r2) \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1196
  then have "s \<in> ALT (der c r1) (der c r2) \<rightarrow> v" by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1197
  then consider (left) v' where "v = Left v'" "s \<in> der c r1 \<rightarrow> v'" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1198
              | (right) v' where "v = Right v'" "s \<notin> L (der c r1)" "s \<in> der c r2 \<rightarrow> v'" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1199
              by cases auto
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1200
  then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v"
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1201
  proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1202
    case left
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1203
    have "s \<in> der c r1 \<rightarrow> v'" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1204
    then have "(c # s) \<in> r1 \<rightarrow> injval r1 c v'" using IH1 by simp
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1205
    then have "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c (Left v')" by (auto intro: Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1206
    then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" using left by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1207
  next 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1208
    case right
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1209
    have "s \<notin> L (der c r1)" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1210
    then have "c # s \<notin> L r1" by (simp add: der_correctness Der_def)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1211
    moreover 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1212
    have "s \<in> der c r2 \<rightarrow> v'" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1213
    then have "(c # s) \<in> r2 \<rightarrow> injval r2 c v'" using IH2 by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1214
    ultimately have "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c (Right v')" 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1215
      by (auto intro: Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1216
    then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" using right by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1217
  qed
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1218
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1219
  case (SEQ r1 r2)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1220
  have IH1: "\<And>s v. s \<in> der c r1 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r1 \<rightarrow> injval r1 c v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1221
  have IH2: "\<And>s v. s \<in> der c r2 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r2 \<rightarrow> injval r2 c v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1222
  have "s \<in> der c (SEQ r1 r2) \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1223
  then consider 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1224
        (left_nullable) v1 v2 s1 s2 where 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1225
        "v = Left (Seq v1 v2)"  "s = s1 @ s2" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1226
        "s1 \<in> der c r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" "nullable r1" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1227
        "\<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 (der c r1) \<and> s\<^sub>4 \<in> L r2)"
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1228
      | (right_nullable) v1 s1 s2 where 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1229
        "v = Right v1" "s = s1 @ s2"  
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1230
        "s \<in> der c r2 \<rightarrow> v1" "nullable r1" "s1 @ s2 \<notin> L (SEQ (der c r1) r2)"
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1231
      | (not_nullable) v1 v2 s1 s2 where
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1232
        "v = Seq v1 v2" "s = s1 @ s2" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1233
        "s1 \<in> der c r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" "\<not>nullable r1" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1234
        "\<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 (der c r1) \<and> s\<^sub>4 \<in> L r2)"
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1235
        by (force split: if_splits elim!: Posix_elims simp add: Sequ_def der_correctness Der_def)   
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1236
  then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1237
    proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1238
      case left_nullable
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1239
      have "s1 \<in> der c r1 \<rightarrow> v1" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1240
      then have "(c # s1) \<in> r1 \<rightarrow> injval r1 c v1" using IH1 by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1241
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1242
      have "\<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 (der c r1) \<and> s\<^sub>4 \<in> L r2)" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1243
      then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by (simp add: der_correctness Der_def)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1244
      ultimately have "((c # s1) @ s2) \<in> SEQ r1 r2 \<rightarrow> Seq (injval r1 c v1) v2" using left_nullable by (rule_tac Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1245
      then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using left_nullable by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1246
    next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1247
      case right_nullable
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1248
      have "nullable r1" by fact
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1249
      then have "[] \<in> r1 \<rightarrow> (mkeps r1)" by (rule Posix_mkeps)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1250
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1251
      have "s \<in> der c r2 \<rightarrow> v1" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1252
      then have "(c # s) \<in> r2 \<rightarrow> (injval r2 c v1)" using IH2 by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1253
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1254
      have "s1 @ s2 \<notin> L (SEQ (der c r1) r2)" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1255
      then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = c # s \<and> [] @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" using right_nullable
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1256
        by(auto simp add: der_correctness Der_def append_eq_Cons_conv Sequ_def)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1257
      ultimately have "([] @ (c # s)) \<in> SEQ r1 r2 \<rightarrow> Seq (mkeps r1) (injval r2 c v1)"
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1258
      by(rule Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1259
      then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using right_nullable by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1260
    next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1261
      case not_nullable
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1262
      have "s1 \<in> der c r1 \<rightarrow> v1" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1263
      then have "(c # s1) \<in> r1 \<rightarrow> injval r1 c v1" using IH1 by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1264
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1265
      have "\<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 (der c r1) \<and> s\<^sub>4 \<in> L r2)" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1266
      then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by (simp add: der_correctness Der_def)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1267
      ultimately have "((c # s1) @ s2) \<in> SEQ r1 r2 \<rightarrow> Seq (injval r1 c v1) v2" using not_nullable 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1268
        by (rule_tac Posix.intros) (simp_all) 
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1269
      then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using not_nullable by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1270
    qed
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1271
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1272
  case (STAR r)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1273
  have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1274
  have "s \<in> der c (STAR r) \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1275
  then consider
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1276
      (cons) v1 vs s1 s2 where 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1277
        "v = Seq v1 (Stars vs)" "s = s1 @ s2" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1278
        "s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (STAR r) \<rightarrow> (Stars vs)"
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1279
        "\<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 (der c r) \<and> s\<^sub>4 \<in> L (STAR r))" 
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1280
        apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros)
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
  1281
        apply(rotate_tac 3)
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1282
        apply(erule_tac Posix_elims(6))
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1283
        apply (simp add: Posix.intros(6))
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1284
        using Posix.intros(7) by blast
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1285
    then show "(c # s) \<in> STAR r \<rightarrow> injval (STAR r) c v" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1286
    proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1287
      case cons
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1288
          have "s1 \<in> der c r \<rightarrow> v1" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1289
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1290
        moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1291
          have "s2 \<in> STAR r \<rightarrow> Stars vs" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1292
        moreover 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1293
          have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1294
          then have "flat (injval r c v1) = (c # s1)" by (rule Posix1)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1295
          then have "flat (injval r c v1) \<noteq> []" by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1296
        moreover 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1297
          have "\<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 (der c r) \<and> s\<^sub>4 \<in> L (STAR r))" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1298
          then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1299
            by (simp add: der_correctness Der_def)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1300
        ultimately 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  1301
        have "((c # s1) @ s2) \<in> STAR r \<rightarrow> Stars (injval r c v1 # vs)" by (rule Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1302
        then show "(c # s) \<in> STAR r \<rightarrow> injval (STAR r) c v" using cons by(simp)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1303
    qed
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1304
next 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1305
  case (UPNTIMES r n)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1306
  have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1307
  have "s \<in> der c (UPNTIMES r n) \<rightarrow> v" by fact
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1308
  then consider
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1309
      (cons) m v1 vs s1 s2 where 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1310
        "n = Suc m"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1311
        "v = Seq v1 (Stars vs)" "s = s1 @ s2" 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1312
        "s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (UPNTIMES r m) \<rightarrow> (Stars vs)"
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1313
        "\<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 (der c r) \<and> s\<^sub>4 \<in> L (UPNTIMES r m))" 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1314
        apply(case_tac n)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1315
        apply(simp)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1316
        using Posix_elims(1) apply blast
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1317
        apply(simp)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1318
        apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros)        
220
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1319
        by (metis Posix1a UPNTIMES_Stars)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1320
    then show "(c # s) \<in> UPNTIMES r n \<rightarrow> injval (UPNTIMES r n) c v" 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1321
    proof (cases)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1322
      case cons
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1323
        have "n = Suc m" by fact
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1324
        moreover
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1325
          have "s1 \<in> der c r \<rightarrow> v1" by fact
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1326
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1327
        moreover
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1328
          have "s2 \<in> UPNTIMES r m \<rightarrow> Stars vs" by fact
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1329
        moreover 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1330
          have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1331
          then have "flat (injval r c v1) = (c # s1)" by (rule Posix1)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1332
          then have "flat (injval r c v1) \<noteq> []" by simp
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1333
        moreover 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1334
          have "\<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 (der c r) \<and> s\<^sub>4 \<in> L (UPNTIMES r m))" by fact
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1335
          then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r m))" 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1336
            by (simp add: der_correctness Der_def)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1337
        ultimately 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1338
        have "((c # s1) @ s2) \<in> UPNTIMES r (Suc m) \<rightarrow> Stars (injval r c v1 # vs)" 
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1339
          apply(rule_tac Posix.intros(8))
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1340
          apply(simp_all)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1341
          done
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1342
        then show "(c # s) \<in> UPNTIMES r n \<rightarrow> injval (UPNTIMES r n) c v" using cons by(simp)
a8b32da484df updated
Christian Urban <urbanc@in.tum.de>
parents: 216
diff changeset
  1343
    qed
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1344
next 
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1345
  case (NTIMES r n)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1346
  have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1347
  have "s \<in> der c (NTIMES r n) \<rightarrow> v" by fact
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1348
  then consider
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1349
      (cons) m v1 vs s1 s2 where 
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1350
        "n = Suc m"
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1351
        "v = Seq v1 (Stars vs)" "s = s1 @ s2" "flat v = [] \<Longrightarrow> flat (Stars vs) = []"
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1352
        "s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (NTIMES r m) \<rightarrow> (Stars vs)"
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1353
        "\<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 (der c r) \<and> s\<^sub>4 \<in> L (NTIMES r m))" 
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1354
        apply(case_tac n)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1355
        apply(simp)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1356
        using Posix_elims(1) apply blast
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1357
        apply(simp)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1358
        apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1359
        by (metis NTIMES_Stars Posix1a)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1360
    then show "(c # s) \<in> NTIMES r n \<rightarrow> injval (NTIMES r n) c v" 
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1361
    proof (cases)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1362
      case cons
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1363
        have "n = Suc m" by fact
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1364
        moreover
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1365
          have "s1 \<in> der c r \<rightarrow> v1" by fact
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1366
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1367
        moreover
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1368
          have "flat v = [] \<Longrightarrow> flat (Stars vs) = []" by fact
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1369
        moreover
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1370
          have "s2 \<in> NTIMES r m \<rightarrow> Stars vs" by fact
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1371
        moreover 
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1372
          have "\<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 (der c r) \<and> s\<^sub>4 \<in> L (NTIMES r m))" by fact
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1373
          then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (NTIMES r m))" 
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1374
            by (simp add: der_correctness Der_def)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1375
        ultimately 
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1376
        have "((c # s1) @ s2) \<in> NTIMES r (Suc m) \<rightarrow> Stars (injval r c v1 # vs)" 
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1377
          apply(rule_tac Posix.intros(10))
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1378
          apply(simp_all)
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1379
          by (simp add: Posix1(2))
221
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1380
        then show "(c # s) \<in> NTIMES r n \<rightarrow> injval (NTIMES r n) c v" using cons by(simp)
c21938d0b396 added also the ntimes case
Christian Urban <urbanc@in.tum.de>
parents: 220
diff changeset
  1381
    qed
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1382
next 
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1383
  case (FROMNTIMES r n)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1384
  have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1385
  have "s \<in> der c (FROMNTIMES r n) \<rightarrow> v" by fact
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1386
  then consider
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1387
        (null) v1 vs s1 s2 where 
224
624b4154325b FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 223
diff changeset
  1388
        "n = 0"
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1389
        "v = Seq v1 (Stars vs)" "s = s1 @ s2" 
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1390
        "s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (FROMNTIMES r 0) \<rightarrow> (Stars vs)"
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1391
        "\<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 (der c r) \<and> s\<^sub>4 \<in> L (FROMNTIMES r 0))" 
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1392
      | (cons) m v1 vs s1 s2 where 
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1393
        "n = Suc m"
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1394
        "v = Seq v1 (Stars vs)" "s = s1 @ s2" "flat v = [] \<Longrightarrow> flat (Stars vs) = []"
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1395
        "s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (FROMNTIMES r m) \<rightarrow> (Stars vs)"
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1396
        "\<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 (der c r) \<and> s\<^sub>4 \<in> L (FROMNTIMES r m))" 
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1397
        apply(case_tac n)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1398
        apply(simp)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1399
        apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1400
        defer
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1401
        apply (metis FROMNTIMES_Stars Posix1a)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1402
        apply(rotate_tac 5)
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1403
        apply(erule Posix.cases)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1404
        apply(simp_all)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1405
        apply(clarify)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1406
        by (simp add: Posix_FROMNTIMES2)
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1407
    then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" 
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1408
    proof (cases)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1409
      case cons
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1410
        have "n = Suc m" by fact
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1411
        moreover
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1412
          have "s1 \<in> der c r \<rightarrow> v1" by fact
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1413
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1414
        moreover
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1415
          have "s2 \<in> FROMNTIMES r m \<rightarrow> Stars vs" by fact
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1416
        moreover
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1417
          have "flat v = [] \<Longrightarrow> flat (Stars vs) = []" by fact
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1418
        moreover 
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1419
          have "\<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 (der c r) \<and> s\<^sub>4 \<in> L (FROMNTIMES r m))" by fact
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1420
          then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (FROMNTIMES r m))" 
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1421
            by (simp add: der_correctness Der_def)
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1422
        ultimately 
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1423
        have "((c # s1) @ s2) \<in> FROMNTIMES r (Suc m) \<rightarrow> Stars (injval r c v1 # vs)" 
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1424
          apply(rule_tac Posix.intros(12))
236
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1425
          apply(simp_all) 
05fa26637da4 updated
Christian Urban <urbanc@in.tum.de>
parents: 235
diff changeset
  1426
          by (simp add: Posix1(2))
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1427
        then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" using cons by(simp)
224
624b4154325b FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 223
diff changeset
  1428
      next
624b4154325b FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 223
diff changeset
  1429
      case null
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1430
      then have "((c # s1) @ s2) \<in> FROMNTIMES r 0 \<rightarrow> Stars (injval r c v1 # vs)"
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1431
      apply(rule_tac Posix.intros)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1432
      apply(rule_tac Posix.intros)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1433
      apply(rule IH)
224
624b4154325b FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 223
diff changeset
  1434
      apply(simp)
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1435
      apply(rotate_tac 4)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1436
      apply(erule Posix.cases)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1437
      apply(simp_all)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1438
      apply (simp add: Posix1a Prf_injval_flat)
228
8b432cef3805 polished some of the definitions
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
  1439
      apply(simp only: Star_def)
225
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1440
      apply(simp only: der_correctness Der_def)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1441
      apply(simp)
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1442
      done
77d5181490ae FROMNTIMES now done
Christian Urban <urbanc@in.tum.de>
parents: 224
diff changeset
  1443
      then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" using null by simp
223
17c079699ea0 FROMNTIMES not yet done
Christian Urban <urbanc@in.tum.de>
parents: 222
diff changeset
  1444
    qed
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1445
next 
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1446
  case (NMTIMES r n m)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1447
  have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1448
  have "s \<in> der c (NMTIMES r n m) \<rightarrow> v" by fact
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1449
  then show "(c # s) \<in> (NMTIMES r n m) \<rightarrow> injval (NMTIMES r n m) c v"
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1450
        apply(case_tac "m < n")
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1451
        apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1452
        using Posix_elims(1) apply blast
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1453
        apply(case_tac n)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1454
        apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1455
        apply(case_tac m)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1456
        apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1457
        apply(erule Posix_elims(1))
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1458
        apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1459
        apply(erule Posix.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1460
        apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1461
        apply(clarify)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1462
        apply(rotate_tac 5)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1463
        apply(frule Posix1a)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1464
        apply(drule UPNTIMES_Stars)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1465
        apply(clarify)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1466
        apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1467
        apply(subst append_Cons[symmetric])
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1468
        apply(rule Posix.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1469
        apply(rule Posix.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1470
        apply(auto)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1471
        apply(rule IH)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1472
        apply blast
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1473
        using Posix1a Prf_injval_flat apply auto[1]
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1474
        apply(simp add: der_correctness Der_def)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1475
        apply blast
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1476
        apply(case_tac m)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1477
        apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1478
        apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1479
        apply(erule Posix.cases)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1480
        apply(simp_all)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1481
        apply(clarify)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1482
        apply(rotate_tac 6)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1483
        apply(frule Posix1a)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1484
        apply(drule NMTIMES_Stars)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1485
        apply(clarify)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1486
        apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1487
        apply(subst append_Cons[symmetric])
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1488
        apply(rule Posix.intros)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1489
        apply(rule IH)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1490
        apply(blast)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1491
        apply(simp)
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1492
        apply(simp add: der_correctness Der_def)
235
f476c98cad28 updated
Christian Urban <urbanc@in.tum.de>
parents: 234
diff changeset
  1493
        using Posix1a Prf_injval_flat list.distinct(1) apply auto[1]
f476c98cad28 updated
Christian Urban <urbanc@in.tum.de>
parents: 234
diff changeset
  1494
        apply(simp add: der_correctness Der_def)
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1495
        done
230
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1496
next 
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1497
  case (PLUS r)
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1498
  have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
80e7a94f6670 just for fun added the case for PLUS (was already proved as FROMNTIMES)
Christian Urban <urbanc@in.tum.de>
parents: 229
diff changeset
  1499
  have "s \<in> der c (PLUS r) \<rightarrow> v" by fact
233
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1500
  then show "(c # s) \<in> PLUS r \<rightarrow> injval (PLUS r) c v"
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1501
  apply -
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1502
  apply(erule Posix.cases)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1503
  apply(simp_all)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1504
  apply(auto)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1505
  apply(rotate_tac 3)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1506
  apply(erule Posix.cases)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1507
  apply(simp_all)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1508
  apply(subst append_Cons[symmetric])
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1509
  apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1510
  using PLUS.hyps apply auto[1]
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1511
  apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1512
  apply(simp)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1513
  apply(simp)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1514
  apply(simp)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1515
  apply(simp)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1516
  apply(simp)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1517
  using Posix1a Prf_injval_flat apply auto[1]
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1518
  apply(simp add: der_correctness Der_def)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1519
  apply(subst append_Nil2[symmetric])
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1520
  apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1521
  using PLUS.hyps apply auto[1]
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1522
  apply(rule Posix.intros)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1523
  apply(simp)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1524
  apply(simp)
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1525
  done  
238
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1526
next
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1527
  case (AND r1 r2)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1528
  then show ?case
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1529
  apply -
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1530
  apply(erule Posix.cases)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1531
  apply(simp_all)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1532
  apply(auto)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1533
  apply(rule Posix.intros)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1534
  apply(simp)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1535
  apply(simp)
2dc1647eab9e added AND-regular expression (intersection/conjunction)
Christian Urban <urbanc@in.tum.de>
parents: 236
diff changeset
  1536
  done
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
  1537
qed
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
  1538
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1539
227
a8749366ad5d NMTIMES case also done
Christian Urban <urbanc@in.tum.de>
parents: 226
diff changeset
  1540
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1541
section {* The Lexer by Sulzmann and Lu  *}
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1542
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1543
fun 
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1544
  lexer :: "rexp \<Rightarrow> string \<Rightarrow> val option"
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1545
where
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1546
  "lexer r [] = (if nullable r then Some(mkeps r) else None)"
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1547
| "lexer r (c#s) = (case (lexer (der c r) s) of  
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1548
                    None \<Rightarrow> None
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1549
                  | Some(v) \<Rightarrow> Some(injval r c v))"
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1550
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1551
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
  1552
lemma lexer_correct_None:
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
  1553
  shows "s \<notin> L r \<longleftrightarrow> lexer r s = None"
120
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
  1554
apply(induct s arbitrary: r)
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
  1555
apply(simp add: nullable_correctness)
120
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
  1556
apply(drule_tac x="der a r" in meta_spec)
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
  1557
apply(auto simp add: der_correctness Der_def)
120
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
  1558
done
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
  1559
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
  1560
lemma lexer_correct_Some:
185
841f7b9c0a6a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 172
diff changeset
  1561
  shows "s \<in> L r \<longleftrightarrow> (\<exists>v. lexer r s = Some(v) \<and> s \<in> r \<rightarrow> v)"
124
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
  1562
apply(induct s arbitrary: r)
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
  1563
apply(auto simp add: Posix_mkeps nullable_correctness)[1]
124
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
  1564
apply(drule_tac x="der a r" in meta_spec)
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
  1565
apply(simp add: der_correctness Der_def)
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
  1566
apply(rule iffI)
172
cdc0bdcfba3f updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
  1567
apply(auto intro: Posix_injval simp add: Posix1(1))
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
  1568
done 
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1569
186
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1570
lemma lexer_correctness:
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1571
  shows "(lexer r s = Some v) \<longleftrightarrow> s \<in> r \<rightarrow> v"
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1572
  and   "(lexer r s = None) \<longleftrightarrow> \<not>(\<exists>v. s \<in> r \<rightarrow> v)"
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1573
using Posix1(1) Posix_determ lexer_correct_None lexer_correct_Some apply fastforce
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1574
using Posix1(1) lexer_correct_None lexer_correct_Some by blast
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1575
233
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1576
value "lexer (PLUS (ALT ONE (SEQ (CHAR (CHR ''a'')) (CHAR (CHR ''b''))))) [CHR ''a'', CHR ''b'']"
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1577
654b542ce8db strengthened PLUS-posix definition
Christian Urban <urbanc@in.tum.de>
parents: 230
diff changeset
  1578
226
d131cd45a346 deleted unused theorems
Christian Urban <urbanc@in.tum.de>
parents: 225
diff changeset
  1579
unused_thms
95
a33d3040bf7e started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
  1580
end