thys/ReStar.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 14 Mar 2016 15:15:29 +0000
changeset 149 ec3d221bfc45
parent 146 da81ffac4b10
child 150 09f81fee11ce
permissions -rw-r--r--
updated
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
   
92
98d0d77005f3 ReStar changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 91
diff changeset
     2
theory ReStar
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
  imports "Main" 
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
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
lemma seq_empty [simp]:
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
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
lemma seq_null [simp]:
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
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
    26
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
    27
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
    28
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    29
definition
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    30
  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
    31
where
112
698967eceaf1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 111
diff changeset
    32
  "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
    33
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    34
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
    35
  shows "Der c {} = {}"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    36
unfolding Der_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    37
by auto
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    38
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    39
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
    40
  shows "Der c {[]} = {}"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    41
unfolding Der_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    42
by auto
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    43
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    44
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
    45
  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
    46
unfolding Der_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    47
by auto
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    48
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    49
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
    50
  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
    51
unfolding Der_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    52
by auto
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    53
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
    54
lemma Der_Sequ [simp]:
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    55
  shows "Der c (A ;; B) = (Der c A) ;; B \<union> (if [] \<in> A then Der c B else {})"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    56
unfolding Der_def Sequ_def
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
    57
by (auto simp add: Cons_eq_append_conv)
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    58
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
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
    60
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
    61
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
inductive_set
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
  Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
  for A :: "string set"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
  start[intro]: "[] \<in> A\<star>"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
| step[intro]:  "\<lbrakk>s1 \<in> A; s2 \<in> A\<star>\<rbrakk> \<Longrightarrow> s1 @ s2 \<in> A\<star>"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    69
lemma star_cases:
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    70
  shows "A\<star> = {[]} \<union> A ;; A\<star>"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    71
unfolding Sequ_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    72
by (auto) (metis Star.simps)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    73
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
lemma star_decomp: 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
  assumes a: "c # x \<in> A\<star>" 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
  shows "\<exists>a b. x = a @ b \<and> c # a \<in> A \<and> b \<in> A\<star>"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
using a
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
by (induct x\<equiv>"c # x" rule: Star.induct) 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
   (auto simp add: append_eq_Cons_conv)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    81
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
    82
  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
    83
proof -    
113
90fe1a1d7d0e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 112
diff changeset
    84
  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
    85
    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
    86
  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
    87
    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
    88
  also have "... = (Der c A) ;; A\<star> \<union> (if [] \<in> A then Der c (A\<star>) else {})"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    89
    by simp
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    90
  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
    91
    unfolding Sequ_def Der_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    92
    by (auto dest: star_decomp)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    93
  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
    94
qed
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    95
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    96
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    97
section {* Regular Expressions *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
datatype rexp =
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   100
  ZERO
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   101
| ONE
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
| CHAR char
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
| SEQ rexp rexp
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
| ALT rexp rexp
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   105
| STAR rexp
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   106
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   107
section {* Semantics of Regular Expressions *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   108
 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
fun
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
  L :: "rexp \<Rightarrow> string set"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
where
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   112
  "L (ZERO) = {}"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   113
| "L (ONE) = {[]}"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   114
| "L (CHAR c) = {[c]}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   115
| "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
   116
| "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
   117
| "L (STAR r) = (L r)\<star>"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   118
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   119
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   120
section {* Nullable, Derivatives *}
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   121
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   122
fun
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   123
 nullable :: "rexp \<Rightarrow> bool"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   124
where
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   125
  "nullable (ZERO) = False"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   126
| "nullable (ONE) = True"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   127
| "nullable (CHAR c) = False"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
| "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
   129
| "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
   130
| "nullable (STAR r) = True"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   132
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   133
fun
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   134
 der :: "char \<Rightarrow> rexp \<Rightarrow> rexp"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   135
where
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   136
  "der c (ZERO) = ZERO"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   137
| "der c (ONE) = ZERO"
111
289728193164 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 110
diff changeset
   138
| "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
   139
| "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
   140
| "der c (SEQ r1 r2) = 
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   141
     (if nullable r1
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   142
      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
   143
      else SEQ (der c r1) r2)"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   144
| "der c (STAR r) = SEQ (der c r) (STAR r)"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   145
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   146
fun 
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   147
 ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   148
where
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   149
  "ders [] r = r"
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   150
| "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
   151
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   152
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
lemma nullable_correctness:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   154
  shows "nullable r  \<longleftrightarrow> [] \<in> (L r)"
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
   155
by (induct r) (auto simp add: Sequ_def) 
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   156
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   157
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   158
lemma der_correctness:
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   159
  shows "L (der c r) = Der c (L r)"
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   160
by (induct r) (simp_all add: nullable_correctness)
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   161
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   162
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   163
section {* Values *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   164
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   165
datatype val = 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   166
  Void
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   167
| Char char
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   168
| Seq val val
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   169
| Right val
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   170
| Left val
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   171
| Stars "val list"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   172
108
73f7dc60c285 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 107
diff changeset
   173
datatype_compat val
73f7dc60c285 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 107
diff changeset
   174
73f7dc60c285 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 107
diff changeset
   175
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   176
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
   177
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   178
fun 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   179
  flat :: "val \<Rightarrow> string"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   180
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   181
  "flat (Void) = []"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   182
| "flat (Char c) = [c]"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   183
| "flat (Left v) = flat v"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   184
| "flat (Right v) = flat v"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   185
| "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
   186
| "flat (Stars []) = []"
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   187
| "flat (Stars (v#vs)) = (flat v) @ (flat (Stars vs))" 
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   188
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
   189
lemma flat_Stars [simp]:
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   190
 "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
   191
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
   192
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
   193
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
section {* Relation between values and regular expressions *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   195
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   196
inductive 
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   197
  Prf :: "val \<Rightarrow> rexp \<Rightarrow> bool" ("\<turnstile> _ : _" [100, 100] 100)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   198
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   199
 "\<lbrakk>\<turnstile> v1 : r1; \<turnstile> v2 : r2\<rbrakk> \<Longrightarrow> \<turnstile> Seq v1 v2 : SEQ r1 r2"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   200
| "\<turnstile> v1 : r1 \<Longrightarrow> \<turnstile> Left v1 : ALT r1 r2"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   201
| "\<turnstile> v2 : r2 \<Longrightarrow> \<turnstile> Right v2 : ALT r1 r2"
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   202
| "\<turnstile> Void : ONE"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   203
| "\<turnstile> Char c : CHAR c"
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   204
| "\<turnstile> Stars [] : STAR r"
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   205
| "\<lbrakk>\<turnstile> v : r; \<turnstile> Stars vs : STAR r\<rbrakk> \<Longrightarrow> \<turnstile> Stars (v # vs) : STAR r"
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   206
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   207
inductive_cases Prf_elims:
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   208
  "\<turnstile> v : ZERO"
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   209
  "\<turnstile> v : SEQ r1 r2"
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   210
  "\<turnstile> v : ALT r1 r2"
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   211
  "\<turnstile> v : ONE"
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   212
  "\<turnstile> v : CHAR c"
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   213
(*  "\<turnstile> vs : STAR r"*)
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   214
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   215
lemma Prf_flat_L:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   216
  assumes "\<turnstile> v : r" shows "flat v \<in> L r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   217
using assms
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   218
apply(induct v r rule: Prf.induct)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   219
apply(auto simp add: Sequ_def)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   220
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   221
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   222
lemma Prf_Stars:
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
   223
  assumes "\<forall>v \<in> set vs. \<turnstile> v : r"
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   224
  shows "\<turnstile> Stars vs : STAR r"
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
   225
using assms
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
   226
apply(induct vs)
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
   227
apply (metis Prf.intros(6))
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
   228
by (metis Prf.intros(7) insert_iff set_simps(2))
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   229
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
   230
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
   231
  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
   232
  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
   233
using assms
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
   234
apply(induct rule: Star.induct)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   235
apply(auto)
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
   236
apply(rule_tac x="[]" in exI)
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
   237
apply(simp)
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
   238
apply(rule_tac x="s1#ss" in exI)
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
   239
apply(simp)
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
   240
done
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
   241
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   242
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
   243
lemma Star_val:
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
   244
  assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<turnstile> v : r"
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
   245
  shows "\<exists>vs. concat (map flat vs) = concat ss \<and> (\<forall>v\<in>set vs. \<turnstile> v : r)"
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
   246
using assms
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
   247
apply(induct ss)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   248
apply(auto)
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
   249
apply (metis empty_iff list.set(1))
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
   250
by (metis concat.simps(2) list.simps(9) set_ConsD)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   251
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   252
lemma L_flat_Prf:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   253
  "L(r) = {flat v | v. \<turnstile> v : r}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   254
apply(induct r)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   255
apply(auto dest: Prf_flat_L simp add: Sequ_def)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   256
apply (metis Prf.intros(4) flat.simps(1))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   257
apply (metis Prf.intros(5) flat.simps(2))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   258
apply (metis Prf.intros(1) flat.simps(5))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   259
apply (metis Prf.intros(2) flat.simps(3))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
apply (metis Prf.intros(3) flat.simps(4))
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   261
apply(auto elim!: Prf_elims)
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
   262
apply(subgoal_tac "\<exists>vs::val list. concat (map flat vs) = x \<and> (\<forall>v \<in> set vs. \<turnstile> v : r)")
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
   263
apply(auto)[1]
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   264
apply(rule_tac x="Stars vs" in exI)
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
   265
apply(simp)
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   266
apply(rule Prf_Stars)
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
   267
apply(simp)
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
   268
apply(drule Star_string)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   269
apply(auto)
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
   270
apply(rule Star_val)
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
   271
apply(simp)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   272
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   273
93
37e3f1174974 extended all proofs that worked before to the Star case...required a stronger notion of non-problematic values |=
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   274
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   275
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
   276
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   277
fun 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   278
  mkeps :: "rexp \<Rightarrow> val"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   279
where
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   280
  "mkeps(ONE) = Void"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   281
| "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   282
| "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
   283
| "mkeps(STAR r) = Stars []"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   284
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   285
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
   286
where
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   287
  "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
   288
| "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
   289
| "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
   290
| "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
   291
| "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
   292
| "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
   293
| "injval (STAR r) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" 
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   294
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   295
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   296
section {* Mkeps, injval *}
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   297
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   298
lemma mkeps_nullable:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   299
  assumes "nullable(r)" 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   300
  shows "\<turnstile> mkeps r : r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   301
using assms
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   302
by (induct rule: nullable.induct) 
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   303
   (auto intro: Prf.intros)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   304
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   305
lemma mkeps_flat:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   306
  assumes "nullable(r)" 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   307
  shows "flat (mkeps r) = []"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   308
using assms
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   309
by (induct rule: nullable.induct) (auto)
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   310
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   311
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   312
lemma Prf_injval:
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   313
  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
   314
  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
   315
using assms
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   316
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
   317
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
   318
(* STAR *)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   319
apply(rotate_tac 2)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   320
apply(erule Prf.cases)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   321
apply(simp_all)[7]
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   322
apply(auto)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   323
apply (metis Prf.intros(6) Prf.intros(7))
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   324
by (metis Prf.intros(7))
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   325
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   326
lemma Prf_injval_flat:
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   327
  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
   328
  shows "flat (injval r c v) = c # (flat v)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   329
using assms
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   330
apply(induct arbitrary: v rule: der.induct)
144
b356c7adf61a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 143
diff changeset
   331
apply(auto elim!: Prf_elims split: if_splits)
b356c7adf61a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 143
diff changeset
   332
apply(metis mkeps_flat)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   333
apply(rotate_tac 2)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   334
apply(erule Prf.cases)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   335
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   336
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   337
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   338
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   339
104
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   340
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
   341
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   342
inductive 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   343
  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
   344
where
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   345
  "[] \<in> ONE \<rightarrow> Void"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   346
| "[c] \<in> (CHAR c) \<rightarrow> (Char c)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   347
| "s \<in> r1 \<rightarrow> v \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Left v)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   348
| "\<lbrakk>s \<in> r2 \<rightarrow> v; s \<notin> L(r1)\<rbrakk> \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Right v)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   349
| "\<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
   350
    \<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
   351
    (s1 @ s2) \<in> (SEQ r1 r2) \<rightarrow> (Seq v1 v2)"
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   352
| "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> STAR r \<rightarrow> Stars vs; flat v \<noteq> [];
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   353
    \<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
   354
    \<Longrightarrow> (s1 @ s2) \<in> STAR r \<rightarrow> Stars (v # vs)"
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   355
| "[] \<in> STAR r \<rightarrow> Stars []"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   356
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   357
inductive_cases Posix_elims:
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   358
  "s \<in> ZERO \<rightarrow> v"
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   359
  "s \<in> ONE \<rightarrow> v"
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   360
  "s \<in> CHAR c \<rightarrow> v"
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   361
  "s \<in> ALT r1 r2 \<rightarrow> v"
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   362
  "s \<in> SEQ r1 r2 \<rightarrow> v"
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   363
  "s \<in> STAR r \<rightarrow> v"
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   364
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   365
lemma Posix1:
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   366
  assumes "s \<in> r \<rightarrow> v"
123
1bee7006b92b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
   367
  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
   368
using assms
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   369
by (induct s r v rule: Posix.induct)
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   370
   (auto simp add: Sequ_def)
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   371
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   372
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   373
lemma Posix1a:
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   374
  assumes "s \<in> r \<rightarrow> v"
123
1bee7006b92b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
   375
  shows "\<turnstile> v : r"
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   376
using assms
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   377
apply(induct s r v rule: Posix.induct)
123
1bee7006b92b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
   378
apply(auto intro: Prf.intros)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   379
done
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   380
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   381
lemma Posix_mkeps:
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   382
  assumes "nullable r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   383
  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
   384
using assms
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   385
apply(induct r)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   386
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
   387
apply(subst append.simps(1)[symmetric])
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   388
apply(rule Posix.intros)
123
1bee7006b92b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
   389
apply(auto)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   390
done
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   391
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   392
(*
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   393
lemma Posix_determ:
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   394
  assumes "s \<in> r \<rightarrow> v1" "s \<in> r \<rightarrow> v2"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   395
  shows "v1 = v2"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   396
using assms
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   397
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   398
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   399
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   400
proof (induct s r v1 arbitrary: v2 rule: Posix.induct)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   401
  case (1 v2)lemma Posix_determ:
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   402
  assumes "s \<in> r \<rightarrow> v1" "s \<in> r \<rightarrow> v2"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   403
  shows "v1 = v2"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   404
using assms
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   405
apply(induct s r v1 arbitrary: v2 rule: Posix.induct)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   406
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   407
apply(simp_all)[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   408
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   409
apply(simp_all)[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   410
apply(rotate_tac 2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   411
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   412
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   413
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   414
apply(force)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   415
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   416
apply(drule Posix1(1))
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   417
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   418
apply(rotate_tac 3)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   419
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   420
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   421
apply(drule Posix1(1))+
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   422
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   423
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   424
apply(rotate_tac 5)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   425
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   426
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   427
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   428
apply(subgoal_tac "s1 = s1a")
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   429
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   430
apply(simp add: append_eq_append_conv2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   431
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   432
apply (metis Posix1(1) append_self_conv)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   433
apply(rotate_tac 6)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   434
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   435
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   436
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   437
apply(subgoal_tac "s1 = s1a")
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   438
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   439
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   440
apply(simp  (no_asm_use) add: append_eq_append_conv2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   441
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   442
apply (metis L.simps(6) Posix1(1) append_self_conv)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   443
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   444
apply(rotate_tac 2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   445
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   446
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   447
using Posix1(2) apply auto[1]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   448
using Posix1(2) apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   449
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   450
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   451
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   452
apply (simp add: Posix1(2))
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   453
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   454
done
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   455
  then have "[] \<in> ONE \<rightarrow> v2" by simp
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   456
  then show "Void = v2"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   457
  apply(auto: elim Posix_elims)[1]  
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   458
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   459
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   460
apply(simp_all)[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   461
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   462
apply(simp_all)[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   463
apply(rotate_tac 2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   464
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   465
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   466
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   467
apply(force)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   468
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   469
apply(drule Posix1(1))
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   470
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   471
apply(rotate_tac 3)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   472
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   473
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   474
apply(drule Posix1(1))+
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   475
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   476
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   477
apply(rotate_tac 5)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   478
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   479
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   480
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   481
apply(subgoal_tac "s1 = s1a")
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   482
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   483
apply(simp add: append_eq_append_conv2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   484
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   485
apply (metis Posix1(1) append_self_conv)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   486
apply(rotate_tac 6)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   487
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   488
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   489
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   490
apply(subgoal_tac "s1 = s1a")
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   491
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   492
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   493
apply(simp  (no_asm_use) add: append_eq_append_conv2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   494
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   495
apply (metis L.simps(6) Posix1(1) append_self_conv)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   496
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   497
apply(rotate_tac 2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   498
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   499
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   500
using Posix1(2) apply auto[1]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   501
using Posix1(2) apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   502
apply(erule Posix.cases)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   503
apply(simp_all (no_asm_use))[7]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   504
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   505
apply (simp add: Posix1(2))
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   506
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   507
done
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   508
*)
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   509
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   510
lemma Posix_determ:
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   511
  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
   512
  shows "v1 = v2"
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   513
using assms
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   514
apply(induct s r v1 arbitrary: v2 rule: Posix.induct)
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   515
apply(erule Posix.cases)
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   516
apply(simp_all)[7]
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   517
apply(erule Posix.cases)
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   518
apply(simp_all)[7]
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   519
apply(rotate_tac 2)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   520
apply(erule Posix.cases)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   521
apply(simp_all (no_asm_use))[7]
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   522
apply(clarify)
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   523
apply(force)
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   524
apply(clarify)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   525
apply(drule Posix1(1))
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   526
apply(simp)
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   527
apply(rotate_tac 3)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   528
apply(erule Posix.cases)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   529
apply(simp_all (no_asm_use))[7]
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   530
apply(drule Posix1(1))+
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   531
apply(simp)
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   532
apply(simp)
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   533
apply(rotate_tac 5)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   534
apply(erule Posix.cases)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   535
apply(simp_all (no_asm_use))[7]
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   536
apply(clarify)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   537
apply(subgoal_tac "s1 = s1a")
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   538
apply(blast)
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   539
apply(simp add: append_eq_append_conv2)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   540
apply(clarify)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   541
apply (metis Posix1(1) append_self_conv)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   542
apply(rotate_tac 6)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   543
apply(erule Posix.cases)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   544
apply(simp_all (no_asm_use))[7]
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   545
apply(clarify)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   546
apply(subgoal_tac "s1 = s1a")
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   547
apply(simp)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   548
apply(blast)
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   549
apply(simp  (no_asm_use) add: append_eq_append_conv2)
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   550
apply(clarify)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   551
apply (metis L.simps(6) Posix1(1) append_self_conv)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   552
apply(clarify)
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   553
apply(rotate_tac 2)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   554
apply(erule Posix.cases)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   555
apply(simp_all (no_asm_use))[7]
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   556
using Posix1(2) apply auto[1]
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   557
using Posix1(2) apply blast
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   558
apply(erule Posix.cases)
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   559
apply(simp_all (no_asm_use))[7]
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   560
apply(clarify)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   561
apply (simp add: Posix1(2))
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   562
apply(simp)
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
   563
done
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   564
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
   565
(* a proof that does not need proj *)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   566
lemma Posix2_roy_version:
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
   567
  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
   568
  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
   569
using assms
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   570
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
   571
  case ZERO
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   572
  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
   573
  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
   574
  then have "False" by cases
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   575
  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
   576
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   577
  case ONE
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   578
  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
   579
  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
   580
  then have "False" by cases
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   581
  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
   582
next 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   583
  case (CHAR d)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   584
  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
   585
  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
   586
  proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   587
    case eq
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   588
    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
   589
    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
   590
    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
   591
    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
   592
    by (auto intro: Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   593
  next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   594
    case ineq
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   595
    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
   596
    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
   597
    then have "False" by cases
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   598
    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
   599
  qed
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   600
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   601
  case (ALT r1 r2)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   602
  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
   603
  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
   604
  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
   605
  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
   606
  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
   607
              | (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
   608
              by cases auto
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   609
  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
   610
  proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   611
    case left
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   612
    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
   613
    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
   614
    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
   615
    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
   616
  next 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   617
    case right
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   618
    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
   619
    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
   620
    moreover 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   621
    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
   622
    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
   623
    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
   624
      by (auto intro: Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   625
    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
   626
  qed
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   627
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   628
  case (SEQ r1 r2)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   629
  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
   630
  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
   631
  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
   632
  then consider 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   633
        (left_nullable) v1 v2 s1 s2 where 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   634
        "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
   635
        "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
   636
        "\<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
   637
      | (right_nullable) v1 s1 s2 where 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   638
        "v = Right v1" "s = s1 @ s2"  
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   639
        "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
   640
      | (not_nullable) v1 v2 s1 s2 where
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   641
        "v = Seq v1 v2" "s = s1 @ s2" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   642
        "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
   643
        "\<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
   644
        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
   645
  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
   646
    proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   647
      case left_nullable
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   648
      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
   649
      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
   650
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   651
      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
   652
      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
   653
      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
   654
      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
   655
    next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   656
      case right_nullable
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   657
      have "nullable r1" by fact
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   658
      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
   659
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   660
      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
   661
      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
   662
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   663
      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
   664
      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
   665
        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
   666
      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
   667
      by(rule Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   668
      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
   669
    next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   670
      case not_nullable
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   671
      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
   672
      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
   673
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   674
      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
   675
      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
   676
      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
   677
        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
   678
      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
   679
    qed
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   680
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   681
  case (STAR r)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   682
  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
   683
  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
   684
  then consider
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   685
      (cons) v1 vs s1 s2 where 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   686
        "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
   687
        "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
   688
        "\<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
   689
        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
   690
        apply(rotate_tac 3)
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   691
        apply(erule_tac Posix_elims(6))
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   692
        apply (simp add: Posix.intros(6))
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   693
        using Posix.intros(7) by blast
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   694
    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
   695
    proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   696
      case cons
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   697
          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
   698
          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
   699
        moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   700
          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
   701
        moreover 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   702
          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
   703
          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
   704
          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
   705
        moreover 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   706
          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
   707
          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
   708
            by (simp add: der_correctness Der_def)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   709
        ultimately 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   710
        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
   711
        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
   712
    qed
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   713
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
   714
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   715
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   716
section {* The Lexer by Sulzmann and Lu  *}
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   717
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   718
fun 
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   719
  lexer :: "rexp \<Rightarrow> string \<Rightarrow> val option"
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   720
where
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   721
  "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
   722
| "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
   723
                    None \<Rightarrow> None
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   724
                  | 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
   725
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   726
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   727
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
   728
lemma lex_correct1:
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
   729
  assumes "s \<notin> L r"
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   730
  shows "lexer r s = None"
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
   731
using assms
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
   732
apply(induct s arbitrary: r)
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   733
apply(simp add: nullable_correctness)
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
   734
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
   735
apply(auto simp add: der_correctness Der_def)
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   736
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
   737
120
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   738
lemma lex_correct1a:
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   739
  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
   740
using assms
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   741
apply(induct s arbitrary: r)
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   742
apply(simp add: nullable_correctness)
120
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   743
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
   744
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
   745
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
   746
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
   747
lemma lex_correct2:
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
   748
  assumes "s \<in> L r"
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   749
  shows "\<exists>v. lexer r s = Some(v) \<and> \<turnstile> v : r \<and> flat v = s"
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
   750
using assms
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
   751
apply(induct s arbitrary: r)
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
   752
apply(simp)
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
   753
apply (metis mkeps_flat mkeps_nullable nullable_correctness)
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
   754
apply(drule_tac x="der a r" in meta_spec)
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
   755
apply(drule meta_mp)
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
   756
apply(simp add: der_correctness Der_def)
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
   757
apply(auto)
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   758
apply (metis Prf_injval)
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
   759
apply(rule Prf_injval_flat)
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
   760
by simp
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
   761
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
   762
lemma lex_correct3:
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
   763
  assumes "s \<in> L r"
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   764
  shows "\<exists>v. lexer r s = Some(v) \<and> s \<in> r \<rightarrow> 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
   765
using assms
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
   766
apply(induct s arbitrary: r)
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
   767
apply(simp)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   768
apply (metis Posix_mkeps nullable_correctness)
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
   769
apply(drule_tac x="der a r" in meta_spec)
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
   770
apply(drule meta_mp)
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
   771
apply(simp add: der_correctness Der_def)
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
   772
apply(auto)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   773
by (metis Posix2_roy_version)
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
   774
120
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   775
lemma lex_correct3a:
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   776
  shows "s \<in> L r \<longleftrightarrow> (\<exists>v. lexer r s = Some(v) \<and> s \<in> r \<rightarrow> v)"
120
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   777
using assms
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   778
apply(induct s arbitrary: r)
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   779
apply(simp)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   780
apply (metis Posix_mkeps nullable_correctness)
120
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   781
apply(drule_tac x="der a r" in meta_spec)
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   782
apply(auto)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   783
apply(metis Posix2_roy_version)
120
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   784
apply(simp add: der_correctness Der_def)
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   785
using lex_correct1a 
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   786
apply fastforce
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   787
apply(simp add: der_correctness Der_def)
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   788
by (simp add: lex_correct1a)
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   789
124
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
   790
lemma lex_correct3b:
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   791
  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
   792
using assms
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
   793
apply(induct s arbitrary: r)
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
   794
apply(simp)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   795
apply (metis Posix_mkeps nullable_correctness)
124
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
   796
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
   797
apply(simp add: der_correctness Der_def)
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   798
apply(case_tac "lexer (der a r) s = None")
124
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
   799
apply(simp)
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
   800
apply(simp)
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
   801
apply(clarify)
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
   802
apply(rule iffI)
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
   803
apply(auto)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   804
apply(rule Posix2_roy_version)
124
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
   805
apply(simp)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   806
using Posix1(1) by auto
124
5378ddbd1381 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 123
diff changeset
   807
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   808
section {* Lexer including simplifications *}
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   809
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
   810
126
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   811
fun F_RIGHT where
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   812
  "F_RIGHT f v = Right (f 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
   813
126
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   814
fun F_LEFT where
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   815
  "F_LEFT f v = Left (f v)"
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   816
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   817
fun F_ALT where
127
b208bc047eed updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 126
diff changeset
   818
  "F_ALT f\<^sub>1 f\<^sub>2 (Right v) = Right (f\<^sub>2 v)"
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   819
| "F_ALT f\<^sub>1 f\<^sub>2 (Left v) = Left (f\<^sub>1 v)"  
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   820
| "F_ALT f1 f2 v = v"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   821
126
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   822
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   823
fun F_SEQ1 where
127
b208bc047eed updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 126
diff changeset
   824
  "F_SEQ1 f\<^sub>1 f\<^sub>2 v = Seq (f\<^sub>1 Void) (f\<^sub>2 v)"
126
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   825
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   826
fun F_SEQ2 where 
127
b208bc047eed updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 126
diff changeset
   827
  "F_SEQ2 f\<^sub>1 f\<^sub>2 v = Seq (f\<^sub>1 v) (f\<^sub>2 Void)"
126
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   828
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   829
fun F_SEQ where 
127
b208bc047eed updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 126
diff changeset
   830
  "F_SEQ f\<^sub>1 f\<^sub>2 (Seq v\<^sub>1 v\<^sub>2) = Seq (f\<^sub>1 v\<^sub>1) (f\<^sub>2 v\<^sub>2)"
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   831
| "F_SEQ f1 f2 v = v"
126
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   832
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   833
fun simp_ALT where
127
b208bc047eed updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 126
diff changeset
   834
  "simp_ALT (ZERO, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (r\<^sub>2, F_RIGHT f\<^sub>2)"
b208bc047eed updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 126
diff changeset
   835
| "simp_ALT (r\<^sub>1, f\<^sub>1) (ZERO, f\<^sub>2) = (r\<^sub>1, F_LEFT f\<^sub>1)"
b208bc047eed updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 126
diff changeset
   836
| "simp_ALT (r\<^sub>1, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (ALT r\<^sub>1 r\<^sub>2, F_ALT f\<^sub>1 f\<^sub>2)"
126
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   837
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   838
fun simp_SEQ where
127
b208bc047eed updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 126
diff changeset
   839
  "simp_SEQ (ONE, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (r\<^sub>2, F_SEQ1 f\<^sub>1 f\<^sub>2)"
b208bc047eed updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 126
diff changeset
   840
| "simp_SEQ (r\<^sub>1, f\<^sub>1) (ONE, f\<^sub>2) = (r\<^sub>1, F_SEQ2 f\<^sub>1 f\<^sub>2)"
b208bc047eed updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 126
diff changeset
   841
| "simp_SEQ (r\<^sub>1, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (SEQ r\<^sub>1 r\<^sub>2, F_SEQ f\<^sub>1 f\<^sub>2)"  
126
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   842
 
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   843
lemma simp_SEQ_simps:
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   844
  "simp_SEQ p1 p2 = (if (fst p1 = ONE) then (fst p2, F_SEQ1 (snd p1) (snd p2))
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   845
                    else (if (fst p2 = ONE) then (fst p1, F_SEQ2 (snd p1) (snd p2))
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   846
                    else (SEQ (fst p1) (fst p2), F_SEQ (snd p1) (snd p2))))"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   847
apply(auto)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   848
apply(case_tac p1)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   849
apply(case_tac p2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   850
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   851
apply(case_tac p1)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   852
apply(case_tac p2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   853
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   854
apply(case_tac a)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   855
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   856
apply(case_tac p1)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   857
apply(case_tac p2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   858
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   859
apply(case_tac p1)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   860
apply(case_tac p2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   861
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   862
apply(case_tac a)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   863
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   864
apply(case_tac aa)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   865
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   866
apply(auto)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   867
apply(case_tac aa)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   868
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   869
apply(case_tac aa)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   870
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   871
apply(case_tac aa)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   872
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   873
apply(case_tac aa)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   874
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   875
done
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   876
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   877
lemma simp_ALT_simps:
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   878
  "simp_ALT p1 p2 = (if (fst p1 = ZERO) then (fst p2, F_RIGHT (snd p2))
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   879
                    else (if (fst p2 = ZERO) then (fst p1, F_LEFT (snd p1))
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   880
                    else (ALT (fst p1) (fst p2), F_ALT (snd p1) (snd p2))))"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   881
apply(auto)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   882
apply(case_tac p1)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   883
apply(case_tac p2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   884
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   885
apply(case_tac p1)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   886
apply(case_tac p2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   887
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   888
apply(case_tac a)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   889
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   890
apply(case_tac p1)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   891
apply(case_tac p2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   892
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   893
apply(case_tac p1)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   894
apply(case_tac p2)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   895
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   896
apply(case_tac a)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   897
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   898
apply(case_tac aa)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   899
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   900
apply(auto)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   901
apply(case_tac aa)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   902
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   903
apply(case_tac aa)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   904
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   905
apply(case_tac aa)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   906
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   907
apply(case_tac aa)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   908
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   909
done
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   910
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   911
126
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   912
fun 
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   913
  simp :: "rexp \<Rightarrow> rexp * (val \<Rightarrow> val)"
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   914
where
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   915
  "simp (ALT r1 r2) = simp_ALT (simp r1) (simp r2)" 
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   916
| "simp (SEQ r1 r2) = simp_SEQ (simp r1) (simp r2)" 
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   917
| "simp r = (r, id)"
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   918
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   919
fun 
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   920
  slexer :: "rexp \<Rightarrow> string \<Rightarrow> val option"
126
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   921
where
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   922
  "slexer 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
   923
| "slexer r (c#s) = (let (rs, fr) = simp (der c r) in
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   924
                         (case (slexer rs s) of  
126
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   925
                            None \<Rightarrow> None
e866678c29cb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 124
diff changeset
   926
                          | Some(v) \<Rightarrow> Some(injval r c (fr v))))"
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
   927
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   928
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   929
lemma L_fst_simp:
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   930
  shows "L(r) = L(fst (simp r))"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   931
using assms
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   932
apply(induct r rule: rexp.induct)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   933
apply(auto simp add: simp_SEQ_simps simp_ALT_simps)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   934
done
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   935
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   936
lemma 
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   937
  shows "\<turnstile> ((snd (simp r)) v) : r \<longleftrightarrow> \<turnstile> v : (fst (simp r))"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   938
using assms
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   939
apply(induct r arbitrary: v rule: simp.induct)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   940
apply(auto simp add: simp_SEQ_simps simp_ALT_simps intro: Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   941
using Prf_elims(3) apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   942
apply(erule Prf_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   943
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   944
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   945
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   946
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   947
apply(erule Prf_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   948
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   949
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   950
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   951
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   952
apply(erule Prf_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   953
apply(case_tac v)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   954
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   955
apply(rule Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   956
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   957
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   958
apply(case_tac v)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   959
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   960
apply(rule Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   961
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   962
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   963
apply(erule Prf_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   964
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   965
apply(rule Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   966
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   967
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   968
apply(rule Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   969
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   970
apply(erule Prf_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   971
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   972
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   973
apply(rule Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   974
apply(erule Prf_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   975
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   976
apply(rule Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   977
apply(erule Prf_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   978
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   979
apply(rule Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   980
apply(erule Prf_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   981
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   982
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   983
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   984
apply(rule Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   985
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   986
using Prf.intros(4) apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   987
apply(erule Prf_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   988
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   989
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   990
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   991
apply(rule Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   992
using Prf.intros(4) apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   993
apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   994
apply(erule Prf_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   995
apply(case_tac v)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   996
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   997
apply(rule Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   998
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   999
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1000
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1001
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1002
apply(erule Prf_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1003
apply(case_tac v)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1004
apply(simp_all)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1005
apply(rule Prf.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1006
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1007
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1008
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1009
done
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1010
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1011
lemma Posix_simp_nullable:
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1012
  assumes "nullable r" "[] \<in> (fst (simp r)) \<rightarrow> v"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1013
  shows "((snd (simp r)) v) = mkeps r"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1014
using assms 
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1015
apply(induct r arbitrary: v)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1016
apply(auto simp add: simp_SEQ_simps simp_ALT_simps)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1017
apply(erule Posix_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1018
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1019
apply(erule Posix_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1020
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1021
using Posix.intros(1) apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1022
using Posix.intros(1) apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1023
using Posix.intros(1) apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1024
apply(erule Posix_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1025
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1026
apply(erule Posix_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1027
apply (metis L_fst_simp nullable.simps(1) nullable_correctness)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1028
apply(erule Posix_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1029
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1030
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1031
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1032
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1033
apply(simp only: L_fst_simp[symmetric])
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1034
apply (simp add: nullable_correctness)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1035
apply(erule Posix_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1036
using L_fst_simp Posix1(1) nullable_correctness apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1037
apply (metis L.simps(1) L_fst_simp Prf_flat_L empty_iff mkeps_nullable)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1038
apply(erule Posix_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1039
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1040
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1041
apply(simp only: L_fst_simp[symmetric])
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1042
apply (simp add: nullable_correctness)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1043
apply(erule Posix_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1044
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1045
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1046
using L_fst_simp Posix1(1) nullable_correctness apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1047
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1048
apply(erule Posix_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1049
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1050
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1051
using Posix1(2) apply auto[1]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1052
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1053
done
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1054
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1055
lemma Posix_simp:
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1056
  assumes "s \<in> (fst (simp r)) \<rightarrow> v" 
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1057
  shows "s \<in> r \<rightarrow> ((snd (simp r)) v)"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1058
using assms
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1059
apply(induct r arbitrary: s v rule: rexp.induct) 
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1060
apply(auto split: if_splits simp add: simp_SEQ_simps simp_ALT_simps)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1061
prefer 3
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1062
apply(erule Posix_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1063
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1064
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1065
apply(rule Posix.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1066
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1067
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1068
apply(auto)[1]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1069
apply(simp add: L_fst_simp[symmetric])
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1070
apply(auto)[1]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1071
prefer 3
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1072
apply(rule Posix.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1073
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1074
apply (metis L.simps(1) L_fst_simp equals0D)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1075
prefer 3
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1076
apply(rule Posix.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1077
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1078
prefer 3
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1079
apply(erule Posix_elims)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1080
apply(clarify)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1081
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1082
apply(rule Posix.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1083
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1084
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1085
apply(rule Posix.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1086
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1087
apply(simp add: L_fst_simp[symmetric])
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1088
apply(subst append.simps[symmetric])
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1089
apply(rule Posix.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1090
prefer 2
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1091
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1092
prefer 2
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1093
apply(auto)[1]
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1094
apply (metis L_fst_simp Posix_elims(2) lex_correct3a)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1095
apply(subst Posix_simp_nullable)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1096
using Posix.intros(1) Posix1(1) nullable_correctness apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1097
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1098
apply(rule Posix.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1099
apply(rule Posix_mkeps)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1100
using Posix.intros(1) Posix1(1) nullable_correctness apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1101
apply(subst append_Nil2[symmetric])
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1102
apply(rule Posix.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1103
apply(blast)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1104
apply(subst Posix_simp_nullable)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1105
using Posix.intros(1) Posix1(1) nullable_correctness apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1106
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1107
apply(rule Posix.intros)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1108
apply(rule Posix_mkeps)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1109
using Posix.intros(1) Posix1(1) nullable_correctness apply blast
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1110
apply(auto)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1111
done
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1112
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1113
lemma slexer_correctness:
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1114
  shows "slexer r s = lexer r s"
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1115
apply(induct s arbitrary: r)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1116
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1117
apply(simp)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1118
apply(auto split: option.split prod.split)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1119
apply (metis L_fst_simp fst_conv lex_correct1a)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1120
using L_fst_simp lex_correct1a apply fastforce
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1121
by (metis Posix_determ Posix_simp fst_conv lex_correct1 lex_correct3a option.distinct(1) option.inject snd_conv)
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1122
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1123
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1124
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1125
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
  1126
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
  1127
end