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