thys/ReStar.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 25 Feb 2016 20:13:41 +0000
changeset 106 489dfa0d7ec9
parent 105 80218dddbb15
child 107 6adda4a667b1
permissions -rw-r--r--
more cleaning and moving unnessary stuff to the end
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
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
    27
section {* Semantic Derivatives of Languages *}
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
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    32
  "Der c A \<equiv> {s. [c] @ s \<in> A}"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    33
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
    34
definition 
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
    35
  Ders :: "string \<Rightarrow> string set \<Rightarrow> string set"
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
    36
where  
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
    37
  "Ders s A \<equiv> {s' | s'. s @ s' \<in> A}"
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
    38
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    39
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
    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_empty [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 {[]} = {}"
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_char [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 {[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
    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
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    54
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
    55
  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
    56
unfolding Der_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    57
by auto
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    58
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
    59
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
    60
  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
    61
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
    62
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
    63
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
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
    65
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
    66
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
inductive_set
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
  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
    69
  for A :: "string set"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
  start[intro]: "[] \<in> A\<star>"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
| 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
    73
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    74
lemma star_cases:
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    75
  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
    76
unfolding Sequ_def
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    77
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
    78
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
lemma star_decomp: 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
  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
    81
  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
    82
using a
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
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
    84
   (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
    85
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    86
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
    87
  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
    88
proof -    
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    89
  have "Der c (A\<star>) = Der c ({[]} \<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
    90
    
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    91
    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
    92
  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
    93
    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
    94
  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
    95
    by simp
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
    96
  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
    97
    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
    98
    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
    99
  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
   100
qed
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   101
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   102
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
section {* Regular Expressions *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   105
datatype rexp =
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   106
  NULL
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   107
| EMPTY
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   108
| CHAR char
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
| SEQ rexp rexp
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
| ALT rexp rexp
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
| STAR rexp
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   112
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   113
section {* Semantics of Regular Expressions *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   114
 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   115
fun
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   116
  L :: "rexp \<Rightarrow> string set"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   117
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   118
  "L (NULL) = {}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   119
| "L (EMPTY) = {[]}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   120
| "L (CHAR c) = {[c]}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   121
| "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
   122
| "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
   123
| "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
   124
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   125
fun
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   126
 nullable :: "rexp \<Rightarrow> bool"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   127
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
  "nullable (NULL) = False"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   129
| "nullable (EMPTY) = True"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   130
| "nullable (CHAR c) = False"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
| "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
   132
| "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
   133
| "nullable (STAR r) = True"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   134
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   135
lemma nullable_correctness:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   136
  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
   137
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
   138
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   139
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   140
section {* Values *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   142
datatype val = 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
  Void
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
| Char char
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   145
| Seq val val
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   146
| Right val
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   147
| Left val
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   148
| Stars "val list"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   149
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   150
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
   151
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   152
fun 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
  flat :: "val \<Rightarrow> string"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   154
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   155
  "flat (Void) = []"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   156
| "flat (Char c) = [c]"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   157
| "flat (Left v) = flat v"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   158
| "flat (Right v) = flat v"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   159
| "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
   160
| "flat (Stars []) = []"
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   161
| "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
   162
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
   163
lemma flat_Stars [simp]:
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   164
 "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
   165
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
   166
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
   167
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   168
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
   169
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   170
inductive 
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   171
  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
   172
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   173
 "\<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
   174
| "\<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
   175
| "\<turnstile> v2 : r2 \<Longrightarrow> \<turnstile> Right v2 : ALT r1 r2"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   176
| "\<turnstile> Void : EMPTY"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   177
| "\<turnstile> Char c : CHAR c"
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   178
| "\<turnstile> Stars [] : STAR r"
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   179
| "\<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
   180
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   181
lemma not_nullable_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
   182
  assumes "\<turnstile> v : r" "\<not> nullable r"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   183
  shows "flat v \<noteq> []"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   184
using assms
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
   185
by (induct) (auto)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   186
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   187
lemma Prf_flat_L:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   188
  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
   189
using assms
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   190
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
   191
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
   192
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   194
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
   195
  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
   196
  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
   197
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
   198
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
   199
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
   200
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
   201
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
   202
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
   203
  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
   204
  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
   205
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
   206
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
   207
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
   208
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
   209
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
   210
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
   211
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
   212
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
   213
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
   214
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
   215
  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
   216
  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
   217
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
   218
apply(induct ss)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   219
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
   220
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
   221
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
   222
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
   223
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   224
lemma L_flat_Prf:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   225
  "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
   226
apply(induct r)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   227
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
   228
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
   229
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
   230
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
   231
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
   232
apply (metis Prf.intros(3) flat.simps(4))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   233
apply(erule Prf.cases)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   234
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
   235
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
   236
apply(auto)[1]
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   237
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
   238
apply(simp)
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   239
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
   240
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
   241
apply(drule Star_string)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   242
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
   243
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
   244
apply(simp)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   245
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   246
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
   247
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   248
section {* Values Sets *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   249
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   250
definition prefix :: "string \<Rightarrow> string \<Rightarrow> bool" ("_ \<sqsubseteq> _" [100, 100] 100)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   251
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   252
  "s1 \<sqsubseteq> s2 \<equiv> \<exists>s3. s1 @ s3 = s2"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   253
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   254
definition sprefix :: "string \<Rightarrow> string \<Rightarrow> bool" ("_ \<sqsubset> _" [100, 100] 100)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   255
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   256
  "s1 \<sqsubset> s2 \<equiv> (s1 \<sqsubseteq> s2 \<and> s1 \<noteq> s2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   257
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   258
lemma length_sprefix:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   259
  "s1 \<sqsubset> s2 \<Longrightarrow> length s1 < length s2"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
unfolding sprefix_def prefix_def
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   261
by (auto)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   262
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   263
definition Prefixes :: "string \<Rightarrow> string set" where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   264
  "Prefixes s \<equiv> {sp. sp \<sqsubseteq> s}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   265
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   266
definition Suffixes :: "string \<Rightarrow> string set" where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   267
  "Suffixes s \<equiv> rev ` (Prefixes (rev s))"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   268
94
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   269
definition SPrefixes :: "string \<Rightarrow> string set" where
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   270
  "SPrefixes s \<equiv> {sp. sp \<sqsubset> s}"
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   271
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   272
definition SSuffixes :: "string \<Rightarrow> string set" where
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   273
  "SSuffixes s \<equiv> rev ` (SPrefixes (rev s))"
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   274
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   275
lemma Suffixes_in: 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   276
  "\<exists>s1. s1 @ s2 = s3 \<Longrightarrow> s2 \<in> Suffixes s3"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   277
unfolding Suffixes_def Prefixes_def prefix_def image_def
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   278
apply(auto)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   279
by (metis rev_rev_ident)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   280
94
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   281
lemma SSuffixes_in: 
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   282
  "\<exists>s1. s1 \<noteq> [] \<and> s1 @ s2 = s3 \<Longrightarrow> s2 \<in> SSuffixes s3"
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   283
unfolding SSuffixes_def Suffixes_def SPrefixes_def Prefixes_def sprefix_def prefix_def image_def
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   284
apply(auto)
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   285
by (metis append_self_conv rev.simps(1) rev_rev_ident)
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   286
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   287
lemma Prefixes_Cons:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   288
  "Prefixes (c # s) = {[]} \<union> {c # sp | sp. sp \<in> Prefixes s}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
unfolding Prefixes_def prefix_def
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
apply(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
   291
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   292
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   293
lemma finite_Prefixes:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   294
  "finite (Prefixes s)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   295
apply(induct s)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   296
apply(auto simp add: Prefixes_def prefix_def)[1]
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   297
apply(simp add: Prefixes_Cons)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   298
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   299
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   300
lemma finite_Suffixes:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   301
  "finite (Suffixes s)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   302
unfolding Suffixes_def
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   303
apply(rule finite_imageI)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   304
apply(rule finite_Prefixes)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   305
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   306
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   307
lemma prefix_Cons:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   308
  "((c # s1) \<sqsubseteq> (c # s2)) = (s1 \<sqsubseteq> s2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   309
apply(auto simp add: prefix_def)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   310
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   311
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   312
lemma prefix_append:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   313
  "((s @ s1) \<sqsubseteq> (s @ s2)) = (s1 \<sqsubseteq> s2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   314
apply(induct s)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   315
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   316
apply(simp add: prefix_Cons)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   317
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   318
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   319
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   320
definition Values :: "rexp \<Rightarrow> string \<Rightarrow> val set" where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   321
  "Values r s \<equiv> {v. \<turnstile> v : r \<and> flat v \<sqsubseteq> s}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   322
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   323
definition rest :: "val \<Rightarrow> string \<Rightarrow> string" where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   324
  "rest v s \<equiv> drop (length (flat v)) s"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   325
94
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   326
lemma rest_Nil:
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   327
  "rest v [] = []"
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   328
apply(simp add: rest_def)
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   329
done
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   330
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   331
lemma rest_Suffixes:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   332
  "rest v s \<in> Suffixes s"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   333
unfolding rest_def
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   334
by (metis Suffixes_in append_take_drop_id)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   335
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   336
lemma Values_recs:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   337
  "Values (NULL) s = {}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   338
  "Values (EMPTY) s = {Void}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   339
  "Values (CHAR c) s = (if [c] \<sqsubseteq> s then {Char c} else {})" 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   340
  "Values (ALT r1 r2) s = {Left v | v. v \<in> Values r1 s} \<union> {Right v | v. v \<in> Values r2 s}"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   341
  "Values (SEQ r1 r2) s = {Seq v1 v2 | v1 v2. v1 \<in> Values r1 s \<and> v2 \<in> Values r2 (rest v1 s)}"
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
   342
  "Values (STAR r) s = 
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   343
      {Stars []} \<union> {Stars (v # vs) | v vs. v \<in> Values r s \<and> Stars vs \<in> Values (STAR r) (rest v s)}"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   344
unfolding Values_def
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   345
apply(auto)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   346
(*NULL*)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   347
apply(erule Prf.cases)
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
   348
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   349
(*EMPTY*)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   350
apply(erule Prf.cases)
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
   351
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   352
apply(rule Prf.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   353
apply (metis append_Nil prefix_def)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   354
(*CHAR*)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   355
apply(erule Prf.cases)
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
   356
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   357
apply(rule Prf.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   358
apply(erule Prf.cases)
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
   359
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   360
(*ALT*)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   361
apply(erule Prf.cases)
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
   362
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   363
apply (metis Prf.intros(2))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   364
apply (metis Prf.intros(3))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   365
(*SEQ*)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   366
apply(erule Prf.cases)
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
   367
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   368
apply (simp add: append_eq_conv_conj prefix_def rest_def)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   369
apply (metis Prf.intros(1))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   370
apply (simp add: append_eq_conv_conj prefix_def rest_def)
94
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   371
(*STAR*)
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   372
apply(erule Prf.cases)
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   373
apply(simp_all)[7]
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   374
apply(rule conjI)
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   375
apply(simp add: prefix_def)
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   376
apply(auto)[1]
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   377
apply(simp add: prefix_def)
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   378
apply(auto)[1]
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   379
apply (metis append_eq_conv_conj rest_def)
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   380
apply (metis Prf.intros(6))
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   381
apply (metis append_Nil prefix_def)
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   382
apply (metis Prf.intros(7))
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   383
by (metis append_eq_conv_conj prefix_append prefix_def rest_def)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   384
94
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   385
lemma finite_image_set2:
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   386
  "finite {x. P x} \<Longrightarrow> finite {y. Q y} \<Longrightarrow> finite {(x, y) | x y. P x \<and> Q y}"
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   387
  by (rule finite_subset [where B = "\<Union>x \<in> {x. P x}. \<Union>y \<in> {y. Q y}. {(x, y)}"]) auto
5b01f7c233f8 proved also finiteness of non-problematic values
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   388
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   389
section {* Sulzmann functions *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   390
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   391
fun 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   392
  mkeps :: "rexp \<Rightarrow> val"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   393
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   394
  "mkeps(EMPTY) = Void"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   395
| "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
   396
| "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
   397
| "mkeps(STAR r) = Stars []"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   398
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   399
section {* Derivatives *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   400
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   401
fun
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   402
 der :: "char \<Rightarrow> rexp \<Rightarrow> rexp"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   403
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   404
  "der c (NULL) = NULL"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   405
| "der c (EMPTY) = NULL"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   406
| "der c (CHAR c') = (if c = c' then EMPTY else NULL)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   407
| "der c (ALT r1 r2) = ALT (der c r1) (der c r2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   408
| "der c (SEQ r1 r2) = 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   409
     (if nullable r1
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   410
      then ALT (SEQ (der c r1) r2) (der c r2)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   411
      else SEQ (der c r1) r2)"
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
   412
| "der c (STAR r) = SEQ (der c r) (STAR r)"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   413
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   414
fun 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   415
 ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   416
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   417
  "ders [] r = r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   418
| "ders (c # s) r = ders s (der c r)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   419
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   420
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   421
lemma der_correctness:
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   422
  shows "L (der c r) = Der c (L r)"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   423
apply(induct r) 
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   424
apply(simp_all add: nullable_correctness)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   425
done
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   426
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   427
lemma ders_correctness:
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   428
  shows "L (ders s r) = Ders s (L r)"
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   429
apply(induct s arbitrary: r) 
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   430
apply(simp add: Ders_def)
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   431
apply(simp)
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   432
apply(subst der_correctness)
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   433
apply(simp add: Ders_def Der_def)
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   434
done
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   435
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   436
section {* Injection function *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   437
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   438
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
   439
where
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   440
  "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
   441
| "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
   442
| "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
   443
| "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
   444
| "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
   445
| "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
   446
| "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
   447
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   448
fun 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   449
  lex :: "rexp \<Rightarrow> string \<Rightarrow> val option"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   450
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   451
  "lex r [] = (if nullable r then Some(mkeps r) else None)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   452
| "lex r (c#s) = (case (lex (der c r) s) of  
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   453
                    None \<Rightarrow> None
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   454
                  | Some(v) \<Rightarrow> Some(injval r c v))"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   455
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   456
fun 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   457
  lex2 :: "rexp \<Rightarrow> string \<Rightarrow> val"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   458
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   459
  "lex2 r [] = mkeps r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   460
| "lex2 r (c#s) = injval r c (lex2 (der c r) s)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   461
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   462
section {* Projection function *}
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   463
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   464
fun projval :: "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
   465
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   466
  "projval (CHAR d) c _ = Void"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   467
| "projval (ALT r1 r2) c (Left v1) = Left (projval r1 c v1)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   468
| "projval (ALT r1 r2) c (Right v2) = Right (projval r2 c v2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   469
| "projval (SEQ r1 r2) c (Seq v1 v2) = 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   470
     (if flat v1 = [] then Right(projval r2 c v2) 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   471
      else if nullable r1 then Left (Seq (projval r1 c v1) v2)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   472
                          else Seq (projval r1 c v1) v2)"
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   473
| "projval (STAR r) c (Stars (v # vs)) = Seq (projval r c v) (Stars vs)"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   474
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   475
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   476
lemma mkeps_nullable:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   477
  assumes "nullable(r)" 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   478
  shows "\<turnstile> mkeps r : r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   479
using assms
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   480
apply(induct rule: nullable.induct)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   481
apply(auto intro: Prf.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   482
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   483
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   484
lemma mkeps_flat:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   485
  assumes "nullable(r)" 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   486
  shows "flat (mkeps r) = []"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   487
using assms
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   488
apply(induct rule: nullable.induct)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   489
apply(auto)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   490
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   491
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   492
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   493
lemma v3:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   494
  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
   495
  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
   496
using assms
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   497
apply(induct arbitrary: v rule: der.induct)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   498
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   499
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   500
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   501
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   502
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   503
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   504
apply(case_tac "c = c'")
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   505
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   506
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   507
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   508
apply (metis Prf.intros(5))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   509
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   510
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   511
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   512
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   513
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   514
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   515
apply (metis Prf.intros(2))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   516
apply (metis Prf.intros(3))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   517
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   518
apply(case_tac "nullable r1")
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   519
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   520
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   521
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   522
apply(auto)[1]
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   523
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   524
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   525
apply(auto)[1]
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   526
apply (metis Prf.intros(1))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   527
apply(auto)[1]
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   528
apply (metis Prf.intros(1) mkeps_nullable)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   529
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   530
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   531
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   532
apply(auto)[1]
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   533
apply(rule Prf.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   534
apply(auto)[2]
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   535
apply(simp)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   536
apply(erule Prf.cases)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   537
apply(simp_all)[7]
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   538
apply(clarify)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   539
apply(rotate_tac 2)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   540
apply(erule Prf.cases)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   541
apply(simp_all)[7]
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   542
apply(auto)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   543
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
   544
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
   545
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
   546
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   547
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   548
lemma v4:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   549
  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
   550
  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
   551
using assms
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   552
apply(induct arbitrary: v rule: der.induct)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   553
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   554
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   555
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   556
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   557
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   558
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   559
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   560
apply(case_tac "c = c'")
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   561
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   562
apply(auto)[1]
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   563
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   564
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   565
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   566
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   567
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   568
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   569
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   570
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   571
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   572
apply(case_tac "nullable r1")
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   573
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   574
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   575
apply(simp_all (no_asm_use))[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   576
apply(auto)[1]
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   577
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   578
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   579
apply(clarify)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   580
apply(simp only: injval.simps flat.simps)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   581
apply(auto)[1]
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   582
apply (metis mkeps_flat)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   583
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   584
apply(erule Prf.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   585
apply(simp_all)[7]
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   586
apply(simp)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   587
apply(erule Prf.cases)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   588
apply(simp_all)[7]
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   589
apply(auto)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   590
apply(rotate_tac 2)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   591
apply(erule Prf.cases)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   592
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   593
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   594
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   595
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   596
104
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   597
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
   598
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   599
inductive 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   600
  PMatch :: "string \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<in> _ \<rightarrow> _" [100, 100, 100] 100)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   601
where
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   602
  "[] \<in> EMPTY \<rightarrow> Void"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   603
| "[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
   604
| "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
   605
| "\<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
   606
| "\<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
   607
    \<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
   608
    (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
   609
| "\<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
   610
    \<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
   611
    \<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
   612
| "[] \<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
   613
101
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   614
lemma PMatch1:
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   615
  assumes "s \<in> r \<rightarrow> v"
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   616
  shows "\<turnstile> v : r" "flat v = s"
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   617
using assms
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   618
apply(induct s r v rule: PMatch.induct)
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   619
apply(auto)
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   620
apply (metis Prf.intros(4))
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   621
apply (metis Prf.intros(5))
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   622
apply (metis Prf.intros(2))
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   623
apply (metis Prf.intros(3))
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   624
apply (metis Prf.intros(1))
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   625
apply (metis Prf.intros(7))
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   626
by (metis Prf.intros(6))
7f4f8c34da95 fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 100
diff changeset
   627
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   628
lemma PMatch_mkeps:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   629
  assumes "nullable r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   630
  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
   631
using assms
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   632
apply(induct r)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   633
apply(auto)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   634
apply (metis PMatch.intros(1))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   635
apply(subst append.simps(1)[symmetric])
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   636
apply (rule PMatch.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   637
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   638
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   639
apply(auto)[1]
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   640
apply (rule PMatch.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   641
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   642
apply (rule PMatch.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   643
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   644
apply (rule PMatch.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   645
apply(simp)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   646
apply (metis nullable_correctness)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   647
apply(metis PMatch.intros(7))
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
   648
done
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   649
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   650
lemma PMatch_determ:
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   651
  shows "\<lbrakk>s \<in> r \<rightarrow> v1; s \<in> r \<rightarrow> v2\<rbrakk> \<Longrightarrow> v1 = v2"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   652
  and   "\<lbrakk>s \<in> (STAR r) \<rightarrow> Stars vs1; s \<in> (STAR r) \<rightarrow> Stars vs2\<rbrakk> \<Longrightarrow> vs1 = vs2"
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   653
apply(induct v1 and vs1 arbitrary: s r v2 and s r vs2 rule: val.inducts)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   654
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   655
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   656
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   657
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   658
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   659
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   660
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   661
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   662
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   663
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   664
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   665
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   666
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   667
apply(subgoal_tac "s1 = s1a \<and> s2 = s2a")
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   668
apply metis
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   669
apply(rule conjI)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   670
apply(simp add: append_eq_append_conv2)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   671
apply(auto)[1]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   672
apply (metis PMatch1(1) PMatch1(2) Prf_flat_L)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   673
apply (metis PMatch1(1) PMatch1(2) Prf_flat_L)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   674
apply(simp add: append_eq_append_conv2)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   675
apply(auto)[1]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   676
apply (metis PMatch1(1) PMatch1(2) Prf_flat_L)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   677
apply (metis PMatch1(1) PMatch1(2) Prf_flat_L)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   678
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   679
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   680
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   681
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   682
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   683
apply(clarify)
104
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   684
apply (metis PMatch1(1) PMatch1(2) Prf_flat_L)
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   685
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   686
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   687
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   688
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   689
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   690
apply(clarify)
104
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   691
apply (metis PMatch1(1) PMatch1(2) Prf_flat_L)
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   692
(* star case *)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   693
defer
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   694
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   695
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   696
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   697
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   698
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   699
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   700
apply (metis PMatch1(2))
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   701
apply(rotate_tac  3)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   702
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   703
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   704
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   705
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   706
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   707
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   708
apply(subgoal_tac "s1 = s1a \<and> s2 = s2a")
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   709
apply metis
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   710
apply(simp add: append_eq_append_conv2)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   711
apply(auto)[1]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   712
apply (metis L.simps(6) PMatch1(1) PMatch1(2) Prf_flat_L)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   713
apply (metis L.simps(6) PMatch1(1) PMatch1(2) Prf_flat_L)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   714
apply (metis L.simps(6) PMatch1(1) PMatch1(2) Prf_flat_L)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   715
apply (metis L.simps(6) PMatch1(1) PMatch1(2) Prf_flat_L)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   716
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   717
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   718
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   719
apply (metis PMatch1(2))
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   720
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   721
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   722
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   723
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   724
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   725
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   726
apply(subgoal_tac "s1 = s1a \<and> s2 = s2a")
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   727
apply(drule_tac x="s1 @ s2" in meta_spec)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   728
apply(drule_tac x="rb" in meta_spec)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   729
apply(drule_tac x="(va#vsa)" in meta_spec)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   730
apply(simp)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   731
apply(drule meta_mp)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   732
apply (metis L.simps(6) PMatch.intros(6))
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   733
apply (metis L.simps(6) PMatch.intros(6))
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   734
apply(simp add: append_eq_append_conv2)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   735
apply(auto)[1]
104
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   736
apply (metis L.simps(6) PMatch1(1) PMatch1(2) Prf_flat_L)
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   737
apply (metis L.simps(6) PMatch1(1) PMatch1(2) Prf_flat_L)
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   738
apply (metis L.simps(6) PMatch1(1) PMatch1(2) Prf_flat_L)
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   739
apply (metis L.simps(6) PMatch1(1) PMatch1(2) Prf_flat_L)
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   740
apply (metis PMatch1(2))
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   741
apply(erule PMatch.cases)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   742
apply(simp_all)[7]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   743
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   744
by (metis PMatch1(2))
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   745
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
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
lemma PMatch_Values:
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
   749
  assumes "s \<in> r \<rightarrow> v"
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
  shows "v \<in> Values r s"
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
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
   752
apply(simp add: Values_def PMatch1)
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
by (metis append_Nil2 prefix_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
   754
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
(* a proof that does not need proj *)
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
lemma PMatch2_roy_version:
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
  assumes "s \<in> (der c r) \<rightarrow> v"
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
   758
  shows "(c#s) \<in> r \<rightarrow> (injval r c v)"
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
   759
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
   760
apply(induct r arbitrary: s v c rule: rexp.induct)
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
apply(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
   762
(* NULL case *)
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
apply(erule PMatch.cases)
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
   764
apply(simp_all)[7]
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
(* EMPTY case *)
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(erule PMatch.cases)
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_all)[7]
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
   768
(* CHAR case *)
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(case_tac "c = char")
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(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
   771
apply(erule PMatch.cases)
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(simp_all)[7]
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
   773
apply (metis PMatch.intros(2))
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
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
   775
apply(erule PMatch.cases)
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
   776
apply(simp_all)[7]
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
   777
(* ALT case *)
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
   778
prefer 2
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
   779
apply(erule PMatch.cases)
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
   780
apply(simp_all)[7]
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
   781
apply (metis PMatch.intros(3))
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
   782
apply(clarify)
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
   783
apply(rule PMatch.intros)
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
   784
apply metis
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
   785
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
   786
(* SEQ case *)
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
   787
apply(case_tac "nullable rexp1")
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
   788
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
   789
prefer 2
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
   790
(* not-nullbale case *)
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
   791
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
   792
apply(erule PMatch.cases)
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
   793
apply(simp_all)[7]
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
   794
apply(clarify)
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
   795
apply(subst append.simps(2)[symmetric])
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
   796
apply(rule PMatch.intros)
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
   797
apply metis
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
   798
apply metis
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
   799
apply(auto)[1]
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
   800
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
   801
apply(auto)[1]
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
   802
(* nullable case *)
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
   803
apply(erule PMatch.cases)
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
   804
apply(simp_all)[7]
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
   805
(* left case *)
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
   806
apply(clarify)
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
   807
apply(erule PMatch.cases)
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
   808
apply(simp_all)[4]
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
   809
prefer 2
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
apply(clarify)
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
   811
prefer 2
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
   812
apply(clarify)
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
apply(clarify)
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
   814
apply(simp (no_asm))
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
   815
apply(subst append.simps(2)[symmetric])
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
   816
apply(rule PMatch.intros)
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
   817
apply metis
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
   818
apply metis
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
   819
apply(erule contrapos_nn)
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
   820
apply(erule exE)+
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
   821
apply(auto)[1]
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
   822
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
   823
apply metis
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
   824
(* right interesting case *)
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
   825
apply(clarify)
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
   826
apply(subst append.simps(1)[symmetric])
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
   827
apply(rule PMatch.intros)
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
   828
apply (metis PMatch_mkeps)
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
   829
apply metis
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
   830
apply(rule notI)
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
   831
apply(clarify)
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
   832
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
   833
apply(simp add: der_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
   834
apply(simp only: Der_def Sequ_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
   835
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
   836
apply (metis Cons_eq_append_conv)
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
   837
(* Stars case *)
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
   838
apply(erule PMatch.cases)
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
   839
apply(simp_all)[7]
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
   840
apply(clarify)
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
   841
apply(rotate_tac 2)
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
   842
apply(frule_tac PMatch1)
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
   843
apply(erule PMatch.cases)
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
   844
apply(simp_all)[7]
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
   845
apply(subst append.simps(2)[symmetric])
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
   846
apply(rule PMatch.intros)
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
   847
apply metis
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
   848
apply(auto)[1]
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
   849
apply(rule PMatch.intros)
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
   850
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
   851
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
   852
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
   853
apply (metis L.simps(6))
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
   854
apply(subst v4)
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
   855
apply (metis PMatch1)
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
   856
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
   857
apply(auto)[1]
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
   858
apply(drule_tac x="s\<^sub>3" in 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
   859
apply(drule 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
   860
defer
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
   861
apply metis
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
   862
apply(clarify)
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
   863
apply(drule_tac x="s1" 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
   864
apply(drule_tac x="v1" 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
   865
apply(drule_tac x="c" 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
   866
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
   867
apply(rotate_tac 2)
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
   868
apply(drule PMatch.intros(6))
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
   869
apply(rule PMatch.intros(7))
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
   870
(* HERE *)
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
   871
apply (metis PMatch1(1) list.distinct(1) v4)
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
   872
apply (metis Nil_is_append_conv)
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
   873
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
   874
apply(subst der_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
   875
apply(simp add: 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
   876
done 
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
   877
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
   878
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
   879
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
   880
  assumes "s \<notin> L 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
   881
  shows "lex r s = None"
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
   882
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
   883
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
   884
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
   885
apply (metis 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
   886
apply(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
   887
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
   888
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
   889
apply(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
   890
apply(simp add: L_flat_Prf)
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
   891
by (metis v3 v4)
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
   892
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
   893
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
   894
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
   895
  assumes "s \<in> L 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
   896
  shows "\<exists>v. lex r s = Some(v) \<and> \<turnstile> v : r \<and> flat v = s"
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
   897
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
   898
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
   899
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
   900
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
   901
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
   902
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
   903
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
   904
apply(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
   905
apply (metis v3)
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
   906
apply(rule v4)
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
   907
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
   908
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
   909
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
   910
  assumes "s \<in> L 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
   911
  shows "\<exists>v. lex r s = Some(v) \<and> s \<in> r \<rightarrow> v"
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
   912
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
   913
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
   914
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
   915
apply (metis PMatch_mkeps 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
   916
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
   917
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
   918
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
   919
apply(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
   920
by (metis PMatch2_roy_version)
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
   921
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
   922
lemma lex_correct5:
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
   923
  assumes "s \<in> L 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
   924
  shows "s \<in> r \<rightarrow> (lex2 r s)"
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
   925
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
   926
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
   927
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
   928
apply (metis PMatch_mkeps 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
   929
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
   930
apply(rule PMatch2_roy_version)
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
   931
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
   932
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
   933
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
   934
apply(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
   935
done
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
   936
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
   937
lemma 
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
   938
  "lex2 (ALT (CHAR a) (ALT (CHAR b) (SEQ (CHAR a) (CHAR b)))) [a,b] = Right (Right (Seq (Char a) (Char b)))"
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
   939
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
   940
done
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
   941
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
   942
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
   943
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
   944
section {* Connection with Sulzmann's Ordering of values *}
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
   945
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
   946
inductive ValOrd :: "val \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<succ>_ _" [100, 100, 100] 100)
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
   947
where
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
   948
  "v2 \<succ>r2 v2' \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1 v2')" 
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
   949
| "\<lbrakk>v1 \<succ>r1 v1'; v1 \<noteq> v1'\<rbrakk> \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1' v2')" 
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
   950
| "length (flat v1) \<ge> length (flat v2) \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Right v2)"
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
   951
| "length (flat v2) > length (flat v1) \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Left v1)"
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
   952
| "v2 \<succ>r2 v2' \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Right v2')"
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
   953
| "v1 \<succ>r1 v1' \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Left v1')"
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
   954
| "Void \<succ>EMPTY Void"
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
   955
| "(Char c) \<succ>(CHAR c) (Char c)"
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
   956
| "flat (Stars (v # vs)) = [] \<Longrightarrow> (Stars []) \<succ>(STAR r) (Stars (v # vs))"
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
   957
| "flat (Stars (v # vs)) \<noteq> [] \<Longrightarrow> (Stars (v # vs)) \<succ>(STAR r) (Stars [])"
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
   958
| "\<lbrakk>v1 \<succ>r v2; v1 \<noteq> v2\<rbrakk> \<Longrightarrow> (Stars (v1 # vs1)) \<succ>(STAR r) (Stars (v2 # vs2))"
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
   959
| "(Stars vs1) \<succ>(STAR r) (Stars vs2) \<Longrightarrow> (Stars (v # vs1)) \<succ>(STAR r) (Stars (v # vs2))"
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
   960
| "(Stars []) \<succ>(STAR r) (Stars [])"
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
   961
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
   962
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
   963
(* non-problematic values...needed in order to fix the *) 
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
   964
(* proj lemma in Sulzmann & lu *)
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
   965
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
   966
inductive 
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
   967
  NPrf :: "val \<Rightarrow> rexp \<Rightarrow> bool" ("\<Turnstile> _ : _" [100, 100] 100)
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
   968
where
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
   969
 "\<lbrakk>\<Turnstile> v1 : r1; \<Turnstile> v2 : r2\<rbrakk> \<Longrightarrow> \<Turnstile> Seq v1 v2 : SEQ r1 r2"
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
   970
| "\<Turnstile> v1 : r1 \<Longrightarrow> \<Turnstile> Left v1 : ALT r1 r2"
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
   971
| "\<Turnstile> v2 : r2 \<Longrightarrow> \<Turnstile> Right v2 : ALT r1 r2"
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
   972
| "\<Turnstile> Void : EMPTY"
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
   973
| "\<Turnstile> Char c : CHAR c"
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
   974
| "\<Turnstile> Stars [] : STAR 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
   975
| "\<lbrakk>\<Turnstile> v : r; \<Turnstile> Stars vs : STAR r; flat v \<noteq> []\<rbrakk> \<Longrightarrow> \<Turnstile> Stars (v # vs) : STAR 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
   976
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
   977
lemma NPrf_imp_Prf:
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
   978
  assumes "\<Turnstile> v : 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
   979
  shows "\<turnstile> v : 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
   980
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
   981
apply(induct)
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
   982
apply(auto intro: Prf.intros)
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
   983
done
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
   984
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
   985
lemma Star_valN:
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
   986
  assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<Turnstile> v : 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
   987
  shows "\<exists>vs. concat (map flat vs) = concat ss \<and> (\<forall>v\<in>set vs. \<Turnstile> v : 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
   988
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
   989
apply(induct ss)
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
   990
apply(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
   991
apply (metis empty_iff list.set(1))
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
   992
by (metis concat.simps(2) list.simps(9) set_ConsD)
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
   993
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
   994
lemma NPrf_Prf_val:
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
   995
  shows "\<turnstile> v : r \<Longrightarrow> \<exists>v'. flat v' = flat v \<and> \<Turnstile> v' : 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
   996
  and   "\<turnstile> Stars vs : r \<Longrightarrow> \<exists>vs'. flat (Stars vs') = flat (Stars vs) \<and> \<Turnstile> Stars vs' : 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
   997
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
   998
apply(induct v and vs arbitrary: r and r rule: val.inducts)
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
   999
apply(auto)[1]
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
  1000
apply(erule Prf.cases)
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
  1001
apply(simp_all)[7]
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
  1002
apply(rule_tac x="Void" in exI)
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
  1003
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
  1004
apply(rule NPrf.intros)
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
  1005
apply(erule Prf.cases)
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
  1006
apply(simp_all)[7]
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
  1007
apply(rule_tac x="Char c" in exI)
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
  1008
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
  1009
apply(rule NPrf.intros)
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
  1010
apply(erule Prf.cases)
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
  1011
apply(simp_all)[7]
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
  1012
apply(auto)[1]
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
  1013
apply(drule_tac x="r1" 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
  1014
apply(drule_tac x="r2" 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
  1015
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
  1016
apply(auto)[1]
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
  1017
apply(rule_tac x="Seq v' v'a" in exI)
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
  1018
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
  1019
apply (metis NPrf.intros(1))
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
  1020
apply(erule Prf.cases)
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
  1021
apply(simp_all)[7]
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
  1022
apply(clarify)
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
  1023
apply(drule_tac x="r2" 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
  1024
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
  1025
apply(auto)[1]
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
  1026
apply(rule_tac x="Right v'" in exI)
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
  1027
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
  1028
apply (metis NPrf.intros)
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
  1029
apply(erule Prf.cases)
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
  1030
apply(simp_all)[7]
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
  1031
apply(clarify)
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
  1032
apply(drule_tac x="r1" 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
  1033
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
  1034
apply(auto)[1]
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
  1035
apply(rule_tac x="Left v'" in exI)
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
  1036
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
  1037
apply (metis NPrf.intros)
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
  1038
apply(drule_tac x="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
  1039
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
  1040
apply(auto)[1]
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
  1041
apply(rule_tac x="Stars vs'" in exI)
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
  1042
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
  1043
apply(rule_tac x="[]" in exI)
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
  1044
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
  1045
apply(erule Prf.cases)
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
  1046
apply(simp_all)[7]
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
  1047
apply (metis NPrf.intros(6))
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
  1048
apply(erule Prf.cases)
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
  1049
apply(simp_all)[7]
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
  1050
apply(auto)[1]
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
  1051
apply(drule_tac x="ra" 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
  1052
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
  1053
apply(drule_tac x="STAR ra" 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
  1054
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
  1055
apply(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
  1056
apply(case_tac "flat v = []")
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
  1057
apply(rule_tac x="vs'" in exI)
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
  1058
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
  1059
apply(rule_tac x="v' # vs'" in exI)
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
  1060
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
  1061
apply(rule NPrf.intros)
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
  1062
apply(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
  1063
done
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
  1064
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
  1065
lemma NPrf_Prf:
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
  1066
  shows "{flat v | v. \<turnstile> v : r} = {flat v | v. \<Turnstile> v : 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
  1067
apply(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
  1068
apply (metis NPrf_Prf_val(1))
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
  1069
by (metis NPrf_imp_Prf)
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
  1070
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
  1071
lemma NPrf_flat_L:
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
  1072
  assumes "\<Turnstile> v : r" shows "flat v \<in> L 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
  1073
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
  1074
by (metis NPrf_imp_Prf Prf_flat_L)
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
  1075
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
  1076
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
  1077
lemma L_flat_NPrf:
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
  1078
  "L(r) = {flat v | v. \<Turnstile> v : 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
  1079
by (metis L_flat_Prf NPrf_Prf)
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
  1080
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
  1081
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
  1082
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
  1083
lemma v3_proj:
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
  1084
  assumes "\<Turnstile> v : r" and "\<exists>s. (flat v) = c # s"
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
  1085
  shows "\<Turnstile> (projval r c v) : der c 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
  1086
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
  1087
apply(induct rule: NPrf.induct)
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
  1088
prefer 4
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
  1089
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
  1090
prefer 4
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
  1091
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
  1092
apply (metis NPrf.intros(4))
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
  1093
prefer 2
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
  1094
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
  1095
apply (metis NPrf.intros(2))
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
  1096
prefer 2
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
  1097
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
  1098
apply (metis NPrf.intros(3))
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
  1099
apply(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
  1100
apply(rule NPrf.intros)
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
  1101
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
  1102
apply (metis NPrf_imp_Prf not_nullable_flat)
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
  1103
apply(rule NPrf.intros)
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
  1104
apply(rule NPrf.intros)
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
  1105
apply (metis Cons_eq_append_conv)
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
  1106
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
  1107
apply(rule NPrf.intros)
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
  1108
apply (metis Cons_eq_append_conv)
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
  1109
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
  1110
(* Stars case *)
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
  1111
apply(rule NPrf.intros)
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
  1112
apply (metis Cons_eq_append_conv)
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
  1113
apply(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
  1114
done
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
  1115
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
  1116
lemma v4_proj:
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
  1117
  assumes "\<Turnstile> v : r" and "\<exists>s. (flat v) = c # s"
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
  1118
  shows "c # flat (projval r c v) = flat v"
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
  1119
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
  1120
apply(induct rule: NPrf.induct)
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
  1121
prefer 4
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
  1122
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
  1123
prefer 4
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
  1124
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
  1125
prefer 2
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
  1126
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
  1127
prefer 2
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
  1128
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
  1129
apply(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
  1130
apply (metis Cons_eq_append_conv)
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
  1131
apply(simp add: append_eq_Cons_conv)
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
  1132
apply(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
  1133
done
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
  1134
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
  1135
lemma v4_proj2:
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
  1136
  assumes "\<Turnstile> v : r" and "(flat v) = c # s"
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
  1137
  shows "flat (projval r c v) = s"
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
  1138
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
  1139
by (metis list.inject v4_proj)
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
  1140
104
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1141
lemma PMatch1N:
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1142
  assumes "s \<in> r \<rightarrow> v"
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1143
  shows "\<Turnstile> v : r" 
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1144
using assms
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1145
apply(induct s r v rule: PMatch.induct)
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1146
apply(auto)
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1147
apply (metis NPrf.intros(4))
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1148
apply (metis NPrf.intros(5))
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1149
apply (metis NPrf.intros(2))
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1150
apply (metis NPrf.intros(3))
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1151
apply (metis NPrf.intros(1))
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1152
apply(rule NPrf.intros)
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1153
apply(simp)
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1154
apply(simp)
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1155
apply(simp)
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1156
apply(rule NPrf.intros)
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1157
done
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1158
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
  1159
(* this version needs proj *)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1160
lemma PMatch2:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1161
  assumes "s \<in> (der c r) \<rightarrow> v"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1162
  shows "(c#s) \<in> r \<rightarrow> (injval r c v)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1163
using assms
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1164
apply(induct c r arbitrary: s v rule: der.induct)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1165
apply(auto)
105
80218dddbb15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1166
(* NULL case *)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1167
apply(erule PMatch.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1168
apply(simp_all)[7]
105
80218dddbb15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1169
(* EMPTY case *)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1170
apply(erule PMatch.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1171
apply(simp_all)[7]
105
80218dddbb15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1172
(* CHAR case *)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1173
apply(case_tac "c = c'")
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1174
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1175
apply(erule PMatch.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1176
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1177
apply (metis PMatch.intros(2))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1178
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1179
apply(erule PMatch.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1180
apply(simp_all)[7]
105
80218dddbb15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1181
(* ALT case *)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1182
apply(erule PMatch.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1183
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1184
apply (metis PMatch.intros(3))
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1185
apply(clarify)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1186
apply(rule PMatch.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1187
apply metis
104
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1188
apply(simp add: der_correctness Der_def)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1189
(* SEQ case *)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1190
apply(case_tac "nullable r1")
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1191
apply(simp)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1192
prefer 2
105
80218dddbb15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1193
(* not-nullbale case *)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1194
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1195
apply(erule PMatch.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1196
apply(simp_all)[7]
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1197
apply(clarify)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1198
apply(subst append.simps(2)[symmetric])
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1199
apply(rule PMatch.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1200
apply metis
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1201
apply metis
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1202
apply(auto)[1]
103
ffe5d850df62 added some slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
  1203
apply(simp add: der_correctness Der_def)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1204
apply(auto)[1]
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1205
(* nullable case *)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1206
apply(erule PMatch.cases)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1207
apply(simp_all)[7]
105
80218dddbb15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1208
(* left case *)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1209
apply(clarify)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1210
apply(erule PMatch.cases)
102
7f589bfecffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 101
diff changeset
  1211
apply(simp_all)[4]
105
80218dddbb15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1212
prefer 2
80218dddbb15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1213
apply(clarify)
80218dddbb15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1214
prefer 2
80218dddbb15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1215
apply(clarify)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1216
apply(clarify)
102
7f589bfecffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 101
diff changeset
  1217
apply(simp (no_asm))
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1218
apply(subst append.simps(2)[symmetric])
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1219
apply(rule PMatch.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1220
apply metis
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1221
apply metis
102
7f589bfecffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 101
diff changeset
  1222
apply(erule contrapos_nn)
7f589bfecffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 101
diff changeset
  1223
apply(erule exE)+
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1224
apply(auto)[1]
104
59bad592a009 updated theories and cleaned them up
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1225
apply(simp add: der_correctness Der_def)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1226
apply metis
105
80218dddbb15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
  1227
(* right interesting case *)
102
7f589bfecffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 101
diff changeset
  1228
apply(clarify)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1229
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1230
apply(subst (asm) L.simps(4)[symmetric])
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1231
apply(simp only: L_flat_Prf)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1232
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1233
apply(subst append.simps(1)[symmetric])
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1234
apply(rule PMatch.intros)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1235
apply (metis PMatch_mkeps)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1236
apply metis
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1237
apply(auto)
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
  1238
apply(simp only: L_flat_NPrf)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1239
apply(simp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1240
apply(auto)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1241
apply(drule_tac x="Seq (projval r1 c v) vb" in spec)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1242
apply(drule mp)
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1243
apply(simp)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1244
apply (metis append_Cons butlast_snoc list.sel(1) neq_Nil_conv rotate1.simps(2) v4_proj2)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1245
apply(subgoal_tac "\<turnstile> projval r1 c v : der c r1")
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
  1246
apply (metis NPrf_imp_Prf Prf.intros(1))
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1247
apply(rule NPrf_imp_Prf)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1248
apply(rule v3_proj)
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
  1249
apply(simp)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1250
apply (metis Cons_eq_append_conv)
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
  1251
(* Stars case *)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1252
apply(erule PMatch.cases)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1253
apply(simp_all)[7]
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1254
apply(clarify)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1255
apply(rotate_tac 2)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1256
apply(frule_tac PMatch1)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1257
apply(erule PMatch.cases)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1258
apply(simp_all)[7]
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1259
apply(subst append.simps(2)[symmetric])
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1260
apply(rule PMatch.intros)
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1261
apply metis
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
  1262
apply(auto)[1]
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
  1263
apply(rule PMatch.intros)
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
  1264
apply(simp)
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
  1265
apply(simp)
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
  1266
apply(simp)
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1267
apply (metis L.simps(6))
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
  1268
apply(subst v4)
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
  1269
apply (metis NPrf_imp_Prf PMatch1N)
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
  1270
apply(simp)
100
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1271
apply(auto)[1]
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1272
apply(drule_tac x="s\<^sub>3" in spec)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1273
apply(drule mp)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1274
defer
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1275
apply metis
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1276
apply(clarify)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1277
apply(drule_tac x="s1" in meta_spec)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1278
apply(drule_tac x="v1" in meta_spec)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1279
apply(simp)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1280
apply(rotate_tac 2)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1281
apply(drule PMatch.intros(6))
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1282
apply(rule PMatch.intros(7))
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1283
apply (metis PMatch1(1) list.distinct(1) v4)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1284
apply (metis Nil_is_append_conv)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1285
apply(simp)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1286
apply(subst der_correctness)
8b919b3d753e strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
  1287
apply(simp add: Der_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
  1288
done 
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1289
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1290
lemma lex_correct4:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1291
  assumes "s \<in> L r"
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
  1292
  shows "\<exists>v. lex r s = Some(v) \<and> \<Turnstile> v : r \<and> flat v = s"
a33d3040bf7e started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
  1293
using lex_correct3[OF assms]
a33d3040bf7e started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
  1294
apply(auto)
a33d3040bf7e started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
  1295
apply (metis PMatch1N)
a33d3040bf7e started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
  1296
by (metis PMatch1(2))
a33d3040bf7e started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
  1297
a33d3040bf7e started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
  1298
a33d3040bf7e started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
  1299
end