thys/Re1.thy.orig
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 06 Oct 2014 15:24:41 +0100
changeset 20 c11651bbebf5
parent 18 8c9349065477
permissions -rw-r--r--
some small changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
     1
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
     2
theory Re1
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
     3
  imports "Main" 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
     4
begin
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
     5
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
     6
section {* Sequential Composition of Sets *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
     7
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
     8
definition
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
     9
  Sequ :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ;; _" [100,100] 100)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    10
where 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    11
  "A ;; B = {s1 @ s2 | s1 s2. s1 \<in> A \<and> s2 \<in> B}"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    12
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    13
text {* Two Simple Properties about Sequential Composition *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    14
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    15
lemma seq_empty [simp]:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    16
  shows "A ;; {[]} = A"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    17
  and   "{[]} ;; A = A"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    18
by (simp_all add: Sequ_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    19
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    20
lemma seq_null [simp]:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    21
  shows "A ;; {} = {}"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    22
  and   "{} ;; A = {}"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    23
by (simp_all add: Sequ_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    24
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    25
section {* Regular Expressions *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    26
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    27
datatype rexp =
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    28
  NULL
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    29
| EMPTY
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    30
| CHAR char
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    31
| SEQ rexp rexp
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    32
| ALT rexp rexp
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    33
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    34
section {* Semantics of Regular Expressions *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    35
 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    36
fun
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    37
  L :: "rexp \<Rightarrow> string set"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    38
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    39
  "L (NULL) = {}"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    40
| "L (EMPTY) = {[]}"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    41
| "L (CHAR c) = {[c]}"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    42
| "L (SEQ r1 r2) = (L r1) ;; (L r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    43
| "L (ALT r1 r2) = (L r1) \<union> (L r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    44
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    45
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    46
section {* Values *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    47
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    48
datatype val = 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    49
  Void
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    50
| Char char
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    51
| Seq val val
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    52
| Right val
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    53
| Left val
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    54
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    55
section {* Relation between values and regular expressions *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    56
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    57
inductive Prf :: "val \<Rightarrow> rexp \<Rightarrow> bool" ("\<turnstile> _ : _" [100, 100] 100)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    58
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    59
 "\<lbrakk>\<turnstile> v1 : r1; \<turnstile> v2 : r2\<rbrakk> \<Longrightarrow> \<turnstile> Seq v1 v2 : SEQ r1 r2"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    60
| "\<turnstile> v1 : r1 \<Longrightarrow> \<turnstile> Left v1 : ALT r1 r2"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    61
| "\<turnstile> v2 : r2 \<Longrightarrow> \<turnstile> Right v2 : ALT r1 r2"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    62
| "\<turnstile> Void : EMPTY"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    63
| "\<turnstile> Char c : CHAR c"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    64
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    65
section {* The string behind a value *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    66
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    67
fun flat :: "val \<Rightarrow> string"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    68
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    69
  "flat(Void) = []"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    70
| "flat(Char c) = [c]"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    71
| "flat(Left v) = flat(v)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    72
| "flat(Right v) = flat(v)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    73
| "flat(Seq v1 v2) = flat(v1) @ flat(v2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    74
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    75
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    76
lemma Prf_flat_L:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    77
  assumes "\<turnstile> v : r" shows "flat v \<in> L r"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    78
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    79
apply(induct)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    80
apply(auto simp add: Sequ_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    81
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    82
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    83
lemma L_flat_Prf:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    84
  "L(r) = {flat v | v. \<turnstile> v : r}"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    85
apply(induct r)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    86
apply(auto dest: Prf_flat_L simp add: Sequ_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    87
apply (metis Prf.intros(4) flat.simps(1))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    88
apply (metis Prf.intros(5) flat.simps(2))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    89
apply (metis Prf.intros(1) flat.simps(5))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    90
apply (metis Prf.intros(2) flat.simps(3))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    91
apply (metis Prf.intros(3) flat.simps(4))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    92
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    93
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    94
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    95
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    96
section {* Ordering of values *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    97
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    98
inductive ValOrd :: "val \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<succ>_ _" [100, 100, 100] 100)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
    99
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   100
  "\<lbrakk>v1 = v1'; v2 \<succ>r2 v2'\<rbrakk> \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1' v2')" 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   101
| "v1  \<succ>r1 v1' \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1' v2')" 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   102
| "length (flat v1) \<ge> length (flat v2) \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Right v2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   103
| "length (flat v2) > length (flat v1) \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Left v1)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   104
| "v2 \<succ>r2 v2' \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Right v2')"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   105
| "v1 \<succ>r1 v1' \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Left v1')"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   106
| "Void \<succ>EMPTY Void"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   107
| "(Char c) \<succ>(CHAR c) (Char c)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   108
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   109
(*
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   110
lemma
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   111
  assumes "r = SEQ (ALT EMPTY EMPTY) (ALT EMPTY (CHAR c))"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   112
  shows "(Seq (Left Void) (Right (Char c))) \<succ>r (Seq (Left Void) (Left Void))"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   113
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   114
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   115
apply(rule ValOrd.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   116
apply(rule ValOrd.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   117
apply(rule ValOrd.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   118
apply(rule ValOrd.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   119
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   120
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   121
*)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   122
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   123
section {* Posix definition *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   124
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   125
definition POSIX :: "val \<Rightarrow> rexp \<Rightarrow> bool" 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   126
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   127
  "POSIX v r \<equiv> (\<forall>v'. (\<turnstile> v' : r \<and> flat v = flat v') \<longrightarrow> v \<succ>r v')"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   128
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   129
(*
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   130
an alternative definition: might cause problems
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   131
with theorem mkeps_POSIX
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   132
*)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   133
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   134
definition POSIX2 :: "val \<Rightarrow> rexp \<Rightarrow> bool" 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   135
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   136
  "POSIX2 v r \<equiv> \<turnstile> v : r \<and> (\<forall>v'. \<turnstile> v' : r \<longrightarrow> v \<succ>r v')"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   137
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   138
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   139
(*
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   140
lemma POSIX_SEQ:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   141
  assumes "POSIX (Seq v1 v2) (SEQ r1 r2)" "\<turnstile> v1 : r1" "\<turnstile> v2 : r2"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   142
  shows "POSIX v1 r1 \<and> POSIX v2 r2"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   143
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   144
unfolding POSIX_def
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   145
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   146
apply(drule_tac x="Seq v' v2" in spec)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   147
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   148
apply (smt Prf.intros(1) ValOrd.simps assms(3) rexp.inject(2) val.distinct(15) val.distinct(17) val.distinct(3) val.distinct(9) val.inject(2))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   149
apply(drule_tac x="Seq v1 v'" in spec)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   150
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   151
by (smt Prf.intros(1) ValOrd.simps rexp.inject(2) val.distinct(15) val.distinct(17) val.distinct(3) val.distinct(9) val.inject(2))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   152
*)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   153
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   154
(*
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   155
lemma POSIX_SEQ_I:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   156
  assumes "POSIX v1 r1" "POSIX v2 r2" 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   157
  shows "POSIX (Seq v1 v2) (SEQ r1 r2)" 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   158
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   159
unfolding POSIX_def
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   160
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   161
apply(rotate_tac 2)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   162
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   163
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   164
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   165
apply(rule ValOrd.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   166
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   167
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   168
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   169
*)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   170
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   171
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   172
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   173
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   174
lemma POSIX_ALT2:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   175
  assumes "POSIX (Left v1) (ALT r1 r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   176
  shows "POSIX v1 r1"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   177
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   178
unfolding POSIX_def
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   179
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   180
apply(drule_tac x="Left v'" in spec)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   181
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   182
apply(drule mp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   183
apply(rule Prf.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   184
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   185
apply(erule ValOrd.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   186
apply(simp_all)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   187
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   188
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   189
lemma POSIX2_ALT:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   190
  assumes "POSIX2 (Left v1) (ALT r1 r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   191
  shows "POSIX2 v1 r1"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   192
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   193
unfolding POSIX2_def
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   194
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   195
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   196
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   197
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   198
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   199
lemma POSIX_ALT2:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   200
lemma POSIX_ALT:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   201
  assumes "POSIX (Left v1) (ALT r1 r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   202
  shows "POSIX v1 r1"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   203
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   204
unfolding POSIX_def
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   205
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   206
apply(drule_tac x="Left v'" in spec)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   207
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   208
apply(drule mp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   209
apply(rule Prf.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   210
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   211
apply(erule ValOrd.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   212
apply(simp_all)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   213
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   214
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   215
lemma POSIX_ALT1a:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   216
  assumes "POSIX (Right v2) (ALT r1 r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   217
  shows "POSIX v2 r2"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   218
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   219
unfolding POSIX_def
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   220
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   221
apply(drule_tac x="Right v'" in spec)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   222
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   223
apply(drule mp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   224
apply(rule Prf.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   225
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   226
apply(erule ValOrd.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   227
apply(simp_all)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   228
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   229
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   230
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   231
lemma POSIX_ALT1b:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   232
  assumes "POSIX (Right v2) (ALT r1 r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   233
  shows "(\<forall>v'. (\<turnstile> v' : r2 \<and> flat v' = flat v2) \<longrightarrow> v2 \<succ>r2 v')"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   234
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   235
apply(drule_tac POSIX_ALT1a)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   236
unfolding POSIX_def
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   237
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   238
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   239
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   240
lemma POSIX_ALT_I1:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   241
  assumes "POSIX v1 r1" 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   242
  shows "POSIX (Left v1) (ALT r1 r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   243
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   244
unfolding POSIX_def
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   245
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   246
apply(rotate_tac 3)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   247
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   248
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   249
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   250
apply(rule ValOrd.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   251
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   252
apply(rule ValOrd.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   253
by simp
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   254
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   255
lemma POSIX_ALT_I2:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   256
  assumes "POSIX v2 r2" "\<forall>v'. \<turnstile> v' : r1 \<longrightarrow> length (flat v2) > length (flat v')"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   257
  shows "POSIX (Right v2) (ALT r1 r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   258
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   259
unfolding POSIX_def
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   260
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   261
apply(rotate_tac 3)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   262
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   263
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   264
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   265
apply(rule ValOrd.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   266
apply metis
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   267
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   268
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   269
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   270
section {* The ordering is reflexive *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   271
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   272
lemma ValOrd_refl:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   273
  assumes "\<turnstile> v : r"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   274
  shows "v \<succ>r v"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   275
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   276
apply(induct)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   277
apply(auto intro: ValOrd.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   278
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   279
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   280
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   281
section {* The Matcher *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   282
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   283
fun
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   284
 nullable :: "rexp \<Rightarrow> bool"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   285
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   286
  "nullable (NULL) = False"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   287
| "nullable (EMPTY) = True"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   288
| "nullable (CHAR c) = False"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   289
| "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   290
| "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   291
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   292
lemma nullable_correctness:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   293
  shows "nullable r  \<longleftrightarrow> [] \<in> (L r)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   294
apply (induct r) 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   295
apply(auto simp add: Sequ_def) 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   296
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   297
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   298
fun mkeps :: "rexp \<Rightarrow> val"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   299
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   300
  "mkeps(EMPTY) = Void"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   301
| "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   302
| "mkeps(ALT r1 r2) = (if nullable(r1) then Left (mkeps r1) else Right (mkeps r2))"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   303
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   304
lemma mkeps_nullable:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   305
  assumes "nullable(r)" shows "\<turnstile> mkeps r : r"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   306
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   307
apply(induct rule: nullable.induct)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   308
apply(auto intro: Prf.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   309
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   310
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   311
lemma mkeps_flat:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   312
  assumes "nullable(r)" shows "flat (mkeps r) = []"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   313
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   314
apply(induct rule: nullable.induct)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   315
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   316
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   317
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   318
text {*
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   319
  The value mkeps returns is always the correct POSIX
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   320
  value.
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   321
*}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   322
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   323
lemma mkeps_POSIX2:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   324
  assumes "nullable r"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   325
  shows "POSIX2 (mkeps r) r"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   326
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   327
apply(induct r)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   328
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   329
apply(simp add: POSIX2_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   330
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   331
lemma mkeps_POSIX:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   332
  assumes "nullable r"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   333
  shows "POSIX (mkeps r) r"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   334
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   335
apply(induct r)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   336
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   337
apply(simp add: POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   338
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   339
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   340
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   341
apply (metis ValOrd.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   342
apply(simp add: POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   343
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   344
apply(simp add: POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   345
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   346
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   347
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   348
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   349
apply (simp add: ValOrd.intros(2) mkeps_flat)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   350
apply(simp add: POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   351
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   352
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   353
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   354
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   355
apply (simp add: ValOrd.intros(6))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   356
apply (simp add: ValOrd.intros(3))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   357
apply(simp add: POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   358
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   359
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   360
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   361
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   362
apply (simp add: ValOrd.intros(6))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   363
apply (simp add: ValOrd.intros(3))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   364
apply(simp add: POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   365
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   366
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   367
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   368
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   369
apply (metis Prf_flat_L mkeps_flat nullable_correctness)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   370
by (simp add: ValOrd.intros(5))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   371
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   372
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   373
section {* Derivatives *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   374
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   375
fun
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   376
 der :: "char \<Rightarrow> rexp \<Rightarrow> rexp"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   377
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   378
  "der c (NULL) = NULL"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   379
| "der c (EMPTY) = NULL"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   380
| "der c (CHAR c') = (if c = c' then EMPTY else NULL)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   381
| "der c (ALT r1 r2) = ALT (der c r1) (der c r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   382
| "der c (SEQ r1 r2) = 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   383
     (if nullable r1
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   384
      then ALT (SEQ (der c r1) r2) (der c r2)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   385
      else SEQ (der c r1) r2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   386
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   387
fun 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   388
 ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   389
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   390
  "ders [] r = r"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   391
| "ders (c # s) r = ders s (der c r)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   392
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   393
section {* Injection function *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   394
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   395
fun injval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   396
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   397
  "injval (CHAR d) c Void = Char d"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   398
| "injval (ALT r1 r2) c (Left v1) = Left(injval r1 c v1)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   399
| "injval (ALT r1 r2) c (Right v2) = Right(injval r2 c v2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   400
| "injval (SEQ r1 r2) c (Seq v1 v2) = Seq (injval r1 c v1) v2"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   401
| "injval (SEQ r1 r2) c (Left (Seq v1 v2)) = Seq (injval r1 c v1) v2"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   402
| "injval (SEQ r1 r2) c (Right v2) = Seq (mkeps r1) (injval r2 c v2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   403
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   404
section {* Projection function *}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   405
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   406
fun projval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   407
where
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   408
  "projval (CHAR d) c _ = Void"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   409
| "projval (ALT r1 r2) c (Left v1) = Left(projval r1 c v1)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   410
| "projval (ALT r1 r2) c (Right v2) = Right(projval r2 c v2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   411
| "projval (SEQ r1 r2) c (Seq v1 v2) = 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   412
     (if flat v1 = [] then Right(projval r2 c v2) 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   413
      else if nullable r1 then Left (Seq (projval r1 c v1) v2)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   414
                          else Seq (projval r1 c v1) v2)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   415
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   416
text {*
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   417
  Injection value is related to r
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   418
*}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   419
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   420
lemma v3:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   421
  assumes "\<turnstile> v : der c r" shows "\<turnstile> (injval r c v) : r"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   422
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   423
apply(induct arbitrary: v rule: der.induct)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   424
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   425
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   426
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   427
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   428
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   429
apply(case_tac "c = c'")
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   430
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   431
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   432
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   433
apply (metis Prf.intros(5))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   434
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   435
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   436
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   437
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   438
apply (metis Prf.intros(2))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   439
apply (metis Prf.intros(3))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   440
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   441
apply(case_tac "nullable r1")
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   442
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   443
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   444
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   445
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   446
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   447
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   448
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   449
apply (metis Prf.intros(1))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   450
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   451
apply (metis Prf.intros(1) mkeps_nullable)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   452
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   453
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   454
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   455
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   456
apply(rule Prf.intros)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   457
apply(auto)[2]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   458
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   459
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   460
text {*
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   461
  The string behin the injection value is an added c
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   462
*}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   463
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   464
lemma v4:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   465
  assumes "\<turnstile> v : der c r" shows "flat (injval r c v) = c # (flat v)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   466
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   467
apply(induct arbitrary: v rule: der.induct)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   468
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   469
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   470
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   471
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   472
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   473
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   474
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   475
apply(case_tac "c = c'")
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   476
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   477
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   478
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   479
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   480
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   481
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   482
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   483
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   484
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   485
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   486
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   487
apply(case_tac "nullable r1")
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   488
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   489
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   490
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   491
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   492
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   493
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   494
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   495
apply (metis mkeps_flat)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   496
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   497
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   498
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   499
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   500
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   501
text {*
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   502
  Injection followed by projection is the identity.
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   503
*}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   504
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   505
lemma proj_inj_id:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   506
  assumes "\<turnstile> v : der c r" 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   507
  shows "projval r c (injval r c v) = v"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   508
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   509
apply(induct r arbitrary: c v rule: rexp.induct)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   510
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   511
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   512
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   513
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   514
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   515
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   516
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   517
apply(case_tac "c = char")
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   518
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   519
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   520
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   521
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   522
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   523
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   524
defer
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   525
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   526
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   527
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   528
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   529
apply(case_tac "nullable rexp1")
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   530
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   531
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   532
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   533
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   534
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   535
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   536
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   537
apply (metis list.distinct(1) v4)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   538
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   539
apply (metis mkeps_flat)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   540
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   541
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   542
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   543
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   544
apply(simp add: v4)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   545
done
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   546
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   547
lemma "\<exists>v. POSIX v r"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   548
apply(induct r)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   549
apply(rule exI)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   550
apply(simp add: POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   551
apply (metis (full_types) Prf_flat_L der.simps(1) der.simps(2) der.simps(3) flat.simps(1) nullable.simps(1) nullable_correctness proj_inj_id projval.simps(1) v3 v4)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   552
apply(rule_tac x = "Void" in exI)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   553
apply(simp add: POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   554
apply (metis POSIX_def flat.simps(1) mkeps.simps(1) mkeps_POSIX nullable.simps(2))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   555
apply(rule_tac x = "Char char" in exI)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   556
apply(simp add: POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   557
apply(auto) [1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   558
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   559
apply(simp_all) [5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   560
apply (metis ValOrd.intros(8))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   561
defer
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   562
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   563
apply (metis POSIX_ALT_I1)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   564
(* maybe it is too early to instantiate this existential quantifier *)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   565
(* potentially this is the wrong POSIX value *)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   566
apply(rule_tac x = "Seq v va" in exI )
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   567
apply(simp (no_asm) add: POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   568
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   569
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   570
apply(simp_all)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   571
apply(case_tac "v \<succ>r1a v1")
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   572
apply (metis ValOrd.intros(2))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   573
apply(simp add: POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   574
apply(case_tac "flat v = flat v1")
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   575
apply(auto)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   576
apply(simp only: append_eq_append_conv2)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   577
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   578
thm append_eq_append_conv2
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   579
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   580
text {* 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   581
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   582
  HERE: Crucial lemma that does not go through in the sequence case. 
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   583
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   584
*}
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   585
lemma v5:
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   586
  assumes "\<turnstile> v : der c r" "POSIX v (der c r)"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   587
  shows "POSIX (injval r c v) r"
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   588
using assms
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   589
apply(induct arbitrary: v rule: der.induct)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   590
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   591
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   592
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   593
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   594
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   595
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   596
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   597
apply(case_tac "c = c'")
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   598
apply(auto simp add: POSIX_def)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   599
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   600
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   601
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   602
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   603
using ValOrd.simps apply blast
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   604
apply(auto)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   605
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   606
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   607
(* base cases done *)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   608
(* ALT case *)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   609
apply(erule Prf.cases)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   610
apply(simp_all)[5]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   611
using POSIX_ALT POSIX_ALT_I1 apply blast
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   612
apply(clarify)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   613
apply(subgoal_tac "POSIX v2 (der c r2)")
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   614
prefer 2
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   615
apply(auto simp add: POSIX_def)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   616
apply (metis POSIX_ALT1a POSIX_def flat.simps(4))
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   617
apply(rotate_tac 1)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   618
apply(drule_tac x="v2" in meta_spec)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   619
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   620
apply(subgoal_tac "\<turnstile> Right (injval r2 c v2) : (ALT r1 r2)")
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   621
prefer 2
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   622
apply (metis Prf.intros(3) v3)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   623
apply(rule ccontr)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   624
apply(auto simp add: POSIX_def)[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   625
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   626
apply(rule allI)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   627
apply(rule impI)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   628
apply(erule conjE)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   629
thm POSIX_ALT_I2
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   630
apply(frule POSIX_ALT1a)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   631
apply(drule POSIX_ALT1b)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   632
apply(rule POSIX_ALT_I2)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   633
apply auto[1]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   634
apply(subst v4)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   635
apply(auto)[2]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   636
apply(rotate_tac 1)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   637
apply(drule_tac x="v2" in meta_spec)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   638
apply(simp)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   639
apply(subst (asm) (4) POSIX_def)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   640
apply(subst (asm) v4)
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   641
apply(auto)[2]
fahadausaf <fahad.ausaf@icloud.com>
parents:
diff changeset
   642
(* stuck in the ALT case *)