thys/#Re1.thy#
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 29 Jan 2015 09:05:40 +0000
changeset 53 38cde0214ad5
parent 50 c603b27083f3
permissions -rw-r--r--
added some lemmas, attempted others
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     1
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     2
theory Re1
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     3
  imports "Main" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     4
begin
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     5
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     6
section {* Sequential Composition of Sets *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     7
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     8
definition
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
     9
  Sequ :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ;; _" [100,100] 100)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    10
where 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    11
  "A ;; B = {s1 @ s2 | s1 s2. s1 \<in> A \<and> s2 \<in> B}"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    12
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    13
text {* Two Simple Properties about Sequential Composition *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    14
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    15
lemma seq_empty [simp]:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    16
  shows "A ;; {[]} = A"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    17
  and   "{[]} ;; A = A"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    18
by (simp_all add: Sequ_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    19
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    20
lemma seq_null [simp]:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    21
  shows "A ;; {} = {}"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    22
  and   "{} ;; A = {}"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    23
by (simp_all add: Sequ_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    24
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    25
section {* Regular Expressions *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    26
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    27
datatype rexp =
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    28
  NULL
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    29
| EMPTY
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    30
| CHAR char
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    31
| SEQ rexp rexp
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    32
| ALT rexp rexp
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    33
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    34
section {* Semantics of Regular Expressions *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    35
 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    36
fun
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    37
  L :: "rexp \<Rightarrow> string set"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    38
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    39
  "L (NULL) = {}"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    40
| "L (EMPTY) = {[]}"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    41
| "L (CHAR c) = {[c]}"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    42
| "L (SEQ r1 r2) = (L r1) ;; (L r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    43
| "L (ALT r1 r2) = (L r1) \<union> (L r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    44
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    45
value "L(CHAR c)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    46
value "L(SEQ(CHAR c)(CHAR b))"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    47
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    48
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    49
section {* Values *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    50
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    51
datatype val = 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    52
  Void
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    53
| Char char
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    54
| Seq val val
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    55
| Right val
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    56
| Left val
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    57
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    58
section {* Relation between values and regular expressions *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    59
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    60
inductive Prf :: "val \<Rightarrow> rexp \<Rightarrow> bool" ("\<turnstile> _ : _" [100, 100] 100)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    61
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    62
 "\<lbrakk>\<turnstile> v1 : r1; \<turnstile> v2 : r2\<rbrakk> \<Longrightarrow> \<turnstile> Seq v1 v2 : SEQ r1 r2"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    63
| "\<turnstile> v1 : r1 \<Longrightarrow> \<turnstile> Left v1 : ALT r1 r2"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    64
| "\<turnstile> v2 : r2 \<Longrightarrow> \<turnstile> Right v2 : ALT r1 r2"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    65
| "\<turnstile> Void : EMPTY"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    66
| "\<turnstile> Char c : CHAR c"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    67
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    68
section {* The string behind a value *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    69
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    70
fun flat :: "val \<Rightarrow> string"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    71
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    72
  "flat(Void) = []"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    73
| "flat(Char c) = [c]"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    74
| "flat(Left v) = flat(v)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    75
| "flat(Right v) = flat(v)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    76
| "flat(Seq v1 v2) = flat(v1) @ flat(v2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    77
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    78
value "flat(Seq(Char c)(Char b))"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    79
value "flat(Right(Void))"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    80
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    81
fun flats :: "val \<Rightarrow> string list"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    82
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    83
  "flats(Void) = [[]]"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    84
| "flats(Char c) = [[c]]"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    85
| "flats(Left v) = flats(v)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    86
| "flats(Right v) = flats(v)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    87
| "flats(Seq v1 v2) = (flats v1) @ (flats v2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    88
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    89
value "flats(Seq(Char c)(Char b))"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    90
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    91
lemma Prf_flat_L:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    92
  assumes "\<turnstile> v : r" shows "flat v \<in> L r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    93
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    94
apply(induct)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    95
apply(auto simp add: Sequ_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    96
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    97
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    98
lemma L_flat_Prf:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
    99
  "L(r) = {flat v | v. \<turnstile> v : r}"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   100
apply(induct r)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   101
apply(auto dest: Prf_flat_L simp add: Sequ_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   102
apply (metis Prf.intros(4) flat.simps(1))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   103
apply (metis Prf.intros(5) flat.simps(2))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   104
apply (metis Prf.intros(1) flat.simps(5))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   105
apply (metis Prf.intros(2) flat.simps(3))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   106
apply (metis Prf.intros(3) flat.simps(4))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   107
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   108
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   109
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   110
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   111
definition definition prefix :: :: "string \<Rightarrow> string \<Rightarrow> bool" ("_ \<sqsubset> _" [100, 100] 100)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   112
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   113
  "s1 \<sqsubset> s2 \<equiv> \<exists>s3. s1 @ s3 = s2"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   114
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   115
section {* Ordering of values *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   116
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   117
inductive ValOrd :: "val \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<succ>_ _" [100, 100, 100] 100)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   118
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   119
  "\<lbrakk>v1 = v1'; v2 \<succ>r2 v2'\<rbrakk> \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1' v2')" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   120
| "v1  \<succ>r1 v1' \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1' v2')" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   121
| "length (flat v1) \<ge> length (flat v2) \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Right v2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   122
| "length (flat v2) > length (flat v1) \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Left v1)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   123
| "v2 \<succ>r2 v2' \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Right v2')"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   124
| "v1 \<succ>r1 v1' \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Left v1')"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   125
| "Void \<succ>EMPTY Void"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   126
| "(Char c) \<succ>(CHAR c) (Char c)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   127
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   128
section {* The ordering is reflexive *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   129
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   130
lemma ValOrd_refl:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   131
  assumes "\<turnstile> v : r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   132
  shows "v \<succ>r v"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   133
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   134
apply(induct)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   135
apply(auto intro: ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   136
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   137
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   138
lemma ValOrd_flats:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   139
  assumes "v1 \<succ>r v2"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   140
  shows "hd (flats v2) = hd (flats v1)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   141
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   142
apply(induct)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   143
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   144
oops
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   145
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   146
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   147
section {* Posix definition *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   148
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   149
definition POSIX :: "val \<Rightarrow> rexp \<Rightarrow> bool" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   150
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   151
  "POSIX v r \<equiv> (\<forall>v'. (\<turnstile> v' : r \<and> flat v = flat v') \<longrightarrow> v \<succ>r v')"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   152
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   153
(*
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   154
an alternative definition: might cause problems
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   155
with theorem mkeps_POSIX
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   156
*)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   157
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   158
definition POSIX2 :: "val \<Rightarrow> rexp \<Rightarrow> bool" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   159
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   160
  "POSIX2 v r \<equiv> \<turnstile> v : r \<and> (\<forall>v'. \<turnstile> v' : r \<longrightarrow> v \<succ>r v')"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   161
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   162
definition POSIX3 :: "val \<Rightarrow> rexp \<Rightarrow> bool" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   163
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   164
  "POSIX3 v r \<equiv> \<turnstile> v : r \<and> (\<forall>v'. (\<turnstile> v' : r \<and> length (flat v') \<le> length(flat v)) \<longrightarrow> v \<succ>r v')"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   165
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   166
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   167
lemma POSIX_SEQ:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   168
  assumes "POSIX (Seq v1 v2) (SEQ r1 r2)" "\<turnstile> v1 : r1" "\<turnstile> v2 : r2"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   169
  shows "POSIX v1 r1 \<and> POSIX v2 r2"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   170
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   171
unfolding POSIX_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   172
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   173
apply(drule_tac x="Seq v' v2" in spec)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   174
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   175
apply(erule impE)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   176
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   177
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   178
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   179
apply(erule ValOrd.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   180
apply(simp_all)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   181
apply(clarify)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   182
defer
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   183
apply(drule_tac x="Seq v1 v'" in spec)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   184
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   185
apply(erule impE)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   186
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   187
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   188
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   189
apply(erule ValOrd.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   190
apply(simp_all)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   191
apply(clarify)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   192
oops (*not true*)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   193
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   194
lemma POSIX_SEQ_I:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   195
  assumes "POSIX v1 r1" "POSIX v2 r2" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   196
  shows "POSIX (Seq v1 v2) (SEQ r1 r2)" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   197
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   198
unfolding POSIX_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   199
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   200
apply(rotate_tac 2)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   201
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   202
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   203
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   204
apply(rule ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   205
oops (* maybe also not true *)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   206
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   207
lemma POSIX3_SEQ_I:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   208
  assumes "POSIX3 v1 r1" "POSIX3 v2 r2" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   209
  shows "POSIX3 (Seq v1 v2) (SEQ r1 r2)" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   210
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   211
unfolding POSIX3_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   212
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   213
apply (metis Prf.intros(1))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   214
apply(rotate_tac 4)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   215
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   216
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   217
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   218
apply(case_tac "v1 = v1a")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   219
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   220
apply (metis ValOrd.intros(1))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   221
apply (rule ValOrd.intros(2))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   222
oops
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   223
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   224
lemma POSIX_ALT2:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   225
  assumes "POSIX (Left v1) (ALT r1 r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   226
  shows "POSIX v1 r1"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   227
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   228
unfolding POSIX_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   229
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   230
apply(drule_tac x="Left v'" in spec)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   231
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   232
apply(drule mp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   233
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   234
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   235
apply(erule ValOrd.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   236
apply(simp_all)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   237
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   238
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   239
lemma POSIX2_ALT:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   240
  assumes "POSIX2 (Left v1) (ALT r1 r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   241
  shows "POSIX2 v1 r1"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   242
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   243
unfolding POSIX2_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   244
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   245
oops
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   246
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   247
lemma POSIX_ALT:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   248
  assumes "POSIX (Left v1) (ALT r1 r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   249
  shows "POSIX v1 r1"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   250
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   251
unfolding POSIX_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   252
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   253
apply(drule_tac x="Left v'" in spec)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   254
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   255
apply(drule mp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   256
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   257
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   258
apply(erule ValOrd.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   259
apply(simp_all)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   260
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   261
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   262
lemma POSIX2_ALT:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   263
  assumes "POSIX2 (Left v1) (ALT r1 r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   264
  shows "POSIX2 v1 r1"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   265
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   266
apply(simp add: POSIX2_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   267
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   268
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   269
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   270
apply(drule_tac x="Left v'" in spec)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   271
apply(drule mp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   272
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   273
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   274
apply(erule ValOrd.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   275
apply(simp_all)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   276
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   277
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   278
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   279
lemma POSIX_ALT1a:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   280
  assumes "POSIX (Right v2) (ALT r1 r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   281
  shows "POSIX v2 r2"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   282
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   283
unfolding POSIX_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   284
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   285
apply(drule_tac x="Right v'" in spec)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   286
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   287
apply(drule mp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   288
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   289
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   290
apply(erule ValOrd.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   291
apply(simp_all)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   292
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   293
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   294
lemma POSIX2_ALT1a:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   295
  assumes "POSIX2 (Right v2) (ALT r1 r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   296
  shows "POSIX2 v2 r2"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   297
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   298
unfolding POSIX2_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   299
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   300
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   301
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   302
apply(drule_tac x="Right v'" in spec)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   303
apply(drule mp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   304
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   305
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   306
apply(erule ValOrd.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   307
apply(simp_all)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   308
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   309
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   310
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   311
lemma POSIX_ALT1b:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   312
  assumes "POSIX (Right v2) (ALT r1 r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   313
  shows "(\<forall>v'. (\<turnstile> v' : r2 \<and> flat v' = flat v2) \<longrightarrow> v2 \<succ>r2 v')"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   314
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   315
apply(drule_tac POSIX_ALT1a)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   316
unfolding POSIX_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   317
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   318
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   319
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   320
lemma POSIX_ALT_I1:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   321
  assumes "POSIX v1 r1" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   322
  shows "POSIX (Left v1) (ALT r1 r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   323
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   324
unfolding POSIX_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   325
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   326
apply(rotate_tac 3)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   327
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   328
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   329
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   330
apply(rule ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   331
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   332
apply(rule ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   333
by simp
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   334
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   335
lemma POSIX2_ALT_I1:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   336
  assumes "POSIX2 v1 r1" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   337
  shows "POSIX2 (Left v1) (ALT r1 r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   338
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   339
unfolding POSIX2_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   340
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   341
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   342
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   343
apply(rotate_tac 2)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   344
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   345
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   346
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   347
apply(rule ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   348
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   349
apply(rule ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   350
oops
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   351
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   352
lemma POSIX_ALT_I2:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   353
  assumes "POSIX v2 r2" "\<forall>v'. \<turnstile> v' : r1 \<longrightarrow> length (flat v2) > length (flat v')"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   354
  shows "POSIX (Right v2) (ALT r1 r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   355
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   356
unfolding POSIX_def
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   357
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   358
apply(rotate_tac 3)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   359
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   360
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   361
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   362
apply(rule ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   363
apply metis
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   364
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   365
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   366
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   367
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   368
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   369
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   370
section {* The Matcher *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   371
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   372
fun
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   373
 nullable :: "rexp \<Rightarrow> bool"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   374
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   375
  "nullable (NULL) = False"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   376
| "nullable (EMPTY) = True"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   377
| "nullable (CHAR c) = False"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   378
| "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   379
| "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   380
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   381
lemma nullable_correctness:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   382
  shows "nullable r  \<longleftrightarrow> [] \<in> (L r)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   383
apply (induct r) 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   384
apply(auto simp add: Sequ_def) 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   385
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   386
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   387
fun mkeps :: "rexp \<Rightarrow> val"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   388
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   389
  "mkeps(EMPTY) = Void"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   390
| "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   391
| "mkeps(ALT r1 r2) = (if nullable(r1) then Left (mkeps r1) else Right (mkeps r2))"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   392
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   393
lemma mkeps_nullable:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   394
  assumes "nullable(r)" shows "\<turnstile> mkeps r : r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   395
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   396
apply(induct rule: nullable.induct)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   397
apply(auto intro: Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   398
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   399
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   400
lemma mkeps_flat:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   401
  assumes "nullable(r)" shows "flat (mkeps r) = []"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   402
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   403
apply(induct rule: nullable.induct)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   404
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   405
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   406
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   407
text {*
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   408
  The value mkeps returns is always the correct POSIX
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   409
  value.
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   410
*}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   411
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   412
lemma mkeps_POSIX2:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   413
  assumes "nullable r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   414
  shows "POSIX2 (mkeps r) r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   415
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   416
apply(induct r)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   417
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   418
apply(simp add: POSIX2_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   419
oops
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   420
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   421
lemma mkeps_POSIX3:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   422
  assumes "nullable r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   423
  shows "POSIX3 (mkeps r) r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   424
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   425
apply(induct r)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   426
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   427
apply(simp add: POSIX3_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   428
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   429
apply (metis Prf.intros(4))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   430
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   431
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   432
apply (metis ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   433
apply(simp add: POSIX3_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   434
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   435
apply(simp add: POSIX3_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   436
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   437
apply (metis mkeps.simps(2) mkeps_nullable nullable.simps(5))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   438
apply(rotate_tac 6)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   439
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   440
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   441
apply (metis ValOrd.intros(2) add_leE gen_length_code(1) gen_length_def mkeps_flat)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   442
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   443
apply(simp add: POSIX3_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   444
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   445
apply (metis Prf.intros(2))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   446
apply(rotate_tac 4)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   447
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   448
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   449
apply (metis ValOrd.intros(6))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   450
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   451
apply (metis ValOrd.intros(3))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   452
apply(simp add: POSIX3_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   453
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   454
apply (metis Prf.intros(2))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   455
apply(rotate_tac 6)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   456
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   457
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   458
apply (metis ValOrd.intros(6))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   459
apply (metis ValOrd.intros(3))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   460
apply(simp add: POSIX3_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   461
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   462
apply (metis Prf.intros(3))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   463
apply(rotate_tac 5)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   464
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   465
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   466
apply (metis Prf_flat_L drop_0 drop_all list.size(3) mkeps_flat nullable_correctness)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   467
by (metis ValOrd.intros(5))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   468
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   469
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   470
lemma mkeps_POSIX:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   471
  assumes "nullable r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   472
  shows "POSIX (mkeps r) r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   473
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   474
apply(induct r)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   475
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   476
apply(simp add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   477
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   478
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   479
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   480
apply (metis ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   481
apply(simp add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   482
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   483
apply(simp add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   484
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   485
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   486
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   487
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   488
apply (simp add: ValOrd.intros(2) mkeps_flat)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   489
apply(simp add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   490
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   491
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   492
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   493
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   494
apply (simp add: ValOrd.intros(6))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   495
apply (simp add: ValOrd.intros(3))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   496
apply(simp add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   497
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   498
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   499
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   500
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   501
apply (simp add: ValOrd.intros(6))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   502
apply (simp add: ValOrd.intros(3))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   503
apply(simp add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   504
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   505
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   506
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   507
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   508
apply (metis Prf_flat_L mkeps_flat nullable_correctness)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   509
by (simp add: ValOrd.intros(5))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   510
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   511
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   512
lemma mkeps_POSIX2:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   513
  assumes "nullable r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   514
  shows "POSIX2 (mkeps r) r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   515
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   516
apply(induct r)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   517
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   518
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   519
apply(simp add: POSIX2_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   520
apply(rule conjI)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   521
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   522
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   523
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   524
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   525
apply(rule ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   526
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   527
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   528
apply(simp add: POSIX2_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   529
apply(rule conjI)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   530
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   531
apply(simp add: mkeps_nullable)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   532
apply(simp add: mkeps_nullable)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   533
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   534
apply(rotate_tac 6)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   535
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   536
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   537
apply(rule ValOrd.intros(2))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   538
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   539
apply(simp only: nullable.simps)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   540
apply(erule disjE)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   541
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   542
thm POSIX2_ALT1a
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   543
apply(rule POSIX2_ALT)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   544
apply(simp add: POSIX2_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   545
apply(rule conjI)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   546
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   547
apply(simp add: mkeps_nullable)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   548
oops
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   549
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   550
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   551
section {* Derivatives *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   552
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   553
fun
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   554
 der :: "char \<Rightarrow> rexp \<Rightarrow> rexp"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   555
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   556
  "der c (NULL) = NULL"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   557
| "der c (EMPTY) = NULL"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   558
| "der c (CHAR c') = (if c = c' then EMPTY else NULL)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   559
| "der c (ALT r1 r2) = ALT (der c r1) (der c r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   560
| "der c (SEQ r1 r2) = 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   561
     (if nullable r1
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   562
      then ALT (SEQ (der c r1) r2) (der c r2)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   563
      else SEQ (der c r1) r2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   564
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   565
fun 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   566
 ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   567
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   568
  "ders [] r = r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   569
| "ders (c # s) r = ders s (der c r)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   570
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   571
section {* Injection function *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   572
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   573
fun injval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   574
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   575
  "injval (CHAR d) c Void = Char d"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   576
| "injval (ALT r1 r2) c (Left v1) = Left(injval r1 c v1)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   577
| "injval (ALT r1 r2) c (Right v2) = Right(injval r2 c v2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   578
| "injval (SEQ r1 r2) c (Seq v1 v2) = Seq (injval r1 c v1) v2"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   579
| "injval (SEQ r1 r2) c (Left (Seq v1 v2)) = Seq (injval r1 c v1) v2"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   580
| "injval (SEQ r1 r2) c (Right v2) = Seq (mkeps r1) (injval r2 c v2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   581
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   582
section {* Projection function *}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   583
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   584
fun projval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   585
where
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   586
  "projval (CHAR d) c _ = Void"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   587
| "projval (ALT r1 r2) c (Left v1) = Left(projval r1 c v1)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   588
| "projval (ALT r1 r2) c (Right v2) = Right(projval r2 c v2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   589
| "projval (SEQ r1 r2) c (Seq v1 v2) = 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   590
     (if flat v1 = [] then Right(projval r2 c v2) 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   591
      else if nullable r1 then Left (Seq (projval r1 c v1) v2)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   592
                          else Seq (projval r1 c v1) v2)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   593
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   594
text {*
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   595
  Injection value is related to r
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   596
*}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   597
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   598
lemma v3:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   599
  assumes "\<turnstile> v : der c r" shows "\<turnstile> (injval r c v) : r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   600
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   601
apply(induct arbitrary: v rule: der.induct)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   602
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   603
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   604
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   605
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   606
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   607
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   608
apply(case_tac "c = c'")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   609
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   610
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   611
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   612
apply (metis Prf.intros(5))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   613
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   614
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   615
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   616
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   617
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   618
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   619
apply (metis Prf.intros(2))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   620
apply (metis Prf.intros(3))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   621
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   622
apply(case_tac "nullable r1")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   623
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   624
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   625
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   626
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   627
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   628
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   629
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   630
apply (metis Prf.intros(1))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   631
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   632
apply (metis Prf.intros(1) mkeps_nullable)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   633
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   634
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   635
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   636
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   637
apply(rule Prf.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   638
apply(auto)[2]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   639
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   640
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   641
text {*
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   642
  The string behin the injection value is an added c
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   643
*}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   644
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   645
lemma v4:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   646
  assumes "\<turnstile> v : der c r" shows "flat (injval r c v) = c # (flat v)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   647
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   648
apply(induct arbitrary: v rule: der.induct)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   649
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   650
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   651
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   652
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   653
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   654
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   655
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   656
apply(case_tac "c = c'")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   657
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   658
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   659
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   660
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   661
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   662
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   663
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   664
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   665
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   666
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   667
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   668
apply(case_tac "nullable r1")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   669
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   670
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   671
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   672
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   673
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   674
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   675
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   676
apply (metis mkeps_flat)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   677
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   678
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   679
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   680
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   681
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   682
text {*
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   683
  Injection followed by projection is the identity.
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   684
*}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   685
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   686
lemma proj_inj_id:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   687
  assumes "\<turnstile> v : der c r" 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   688
  shows "projval r c (injval r c v) = v"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   689
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   690
apply(induct r arbitrary: c v rule: rexp.induct)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   691
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   692
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   693
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   694
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   695
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   696
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   697
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   698
apply(case_tac "c = char")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   699
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   700
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   701
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   702
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   703
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   704
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   705
defer
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   706
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   707
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   708
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   709
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   710
apply(case_tac "nullable rexp1")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   711
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   712
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   713
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   714
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   715
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   716
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   717
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   718
apply (metis list.distinct(1) v4)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   719
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   720
apply (metis mkeps_flat)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   721
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   722
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   723
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   724
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   725
apply(simp add: v4)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   726
done
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   727
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   728
lemma "L r \<noteq> {} \<Longrightarrow> \<exists>v. POSIX3 v r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   729
apply(induct r)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   730
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   731
apply(simp add: POSIX3_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   732
apply(rule_tac x="Void" in exI)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   733
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   734
apply (metis Prf.intros(4))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   735
apply (metis POSIX3_def flat.simps(1) mkeps.simps(1) mkeps_POSIX3 nullable.simps(2) order_refl)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   736
apply(simp add: POSIX3_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   737
apply(rule_tac x="Char char" in exI)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   738
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   739
apply (metis Prf.intros(5))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   740
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   741
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   742
apply (metis ValOrd.intros(8))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   743
apply(simp add: Sequ_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   744
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   745
apply(drule meta_mp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   746
apply(auto)[2]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   747
apply(drule meta_mp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   748
apply(auto)[2]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   749
apply(rule_tac x="Seq v va" in exI)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   750
apply(simp (no_asm) add: POSIX3_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   751
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   752
apply (metis POSIX3_def Prf.intros(1))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   753
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   754
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   755
apply(clarify)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   756
apply(case_tac "v  \<succ>r1a v1")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   757
apply(rule ValOrd.intros(2))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   758
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   759
apply(case_tac "v = v1")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   760
apply(rule ValOrd.intros(1))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   761
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   762
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   763
apply (metis ValOrd_refl)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   764
apply(simp add: POSIX3_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   765
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   766
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   767
lemma "\<exists>v. POSIX v r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   768
apply(induct r)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   769
apply(rule exI)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   770
apply(simp add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   771
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)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   772
apply(rule_tac x = "Void" in exI)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   773
apply(simp add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   774
apply (metis POSIX_def flat.simps(1) mkeps.simps(1) mkeps_POSIX nullable.simps(2))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   775
apply(rule_tac x = "Char char" in exI)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   776
apply(simp add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   777
apply(auto) [1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   778
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   779
apply(simp_all) [5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   780
apply (metis ValOrd.intros(8))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   781
defer
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   782
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   783
apply (metis POSIX_ALT_I1)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   784
(* maybe it is too early to instantiate this existential quantifier *)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   785
(* potentially this is the wrong POSIX value *)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   786
apply(case_tac "r1 = NULL")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   787
apply(simp add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   788
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   789
apply (metis L.simps(1) L.simps(4) Prf_flat_L mkeps_flat nullable.simps(1) nullable.simps(2) nullable_correctness seq_null(2))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   790
apply(case_tac "r1 = EMPTY")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   791
apply(rule_tac x = "Seq Void va" in exI )
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   792
apply(simp (no_asm) add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   793
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   794
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   795
apply(simp_all)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   796
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   797
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   798
apply(simp_all)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   799
apply(rule ValOrd.intros(2))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   800
apply(rule ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   801
apply(case_tac "\<exists>c. r1 = CHAR c")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   802
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   803
apply(rule_tac x = "Seq (Char c) va" in exI )
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   804
apply(simp (no_asm) add: POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   805
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   806
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   807
apply(simp_all)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   808
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   809
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   810
apply(simp_all)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   811
apply(auto)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   812
apply(rule ValOrd.intros(2))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   813
apply(rule ValOrd.intros)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   814
apply(case_tac "\<exists>r1a r1b. r1 = ALT r1a r1b")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   815
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   816
oops (* not sure if this can be proved by induction *)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   817
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   818
text {* 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   819
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   820
  HERE: Crucial lemma that does not go through in the sequence case. 
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   821
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   822
*}
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   823
lemma v5:
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   824
  assumes "\<turnstile> v : der c r" "POSIX v (der c r)"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   825
  shows "POSIX (injval r c v) r"
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   826
using assms
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   827
apply(induct arbitrary: v rule: der.induct)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   828
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   829
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   830
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   831
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   832
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   833
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   834
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   835
apply(case_tac "c = c'")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   836
apply(auto simp add: POSIX_def)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   837
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   838
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   839
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   840
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   841
using ValOrd.simps apply blast
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   842
apply(auto)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   843
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   844
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   845
(* base cases done *)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   846
(* ALT case *)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   847
apply(erule Prf.cases)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   848
apply(simp_all)[5]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   849
using POSIX_ALT POSIX_ALT_I1 apply blast
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   850
apply(clarify)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   851
apply(subgoal_tac "POSIX v2 (der c r2)")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   852
prefer 2
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   853
apply(auto simp add: POSIX_def)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   854
apply (metis POSIX_ALT1a POSIX_def flat.simps(4))
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   855
apply(frule POSIX_ALT1a)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   856
apply(drule POSIX_ALT1b)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   857
apply(rule POSIX_ALT_I2)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   858
apply(rotate_tac 1)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   859
apply(drule_tac x="v2" in meta_spec)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   860
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   861
apply(subgoal_tac "\<turnstile> Right (injval r2 c v2) : (ALT r1 r2)")
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   862
prefer 2
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   863
apply (metis Prf.intros(3) v3)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   864
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   865
apply auto[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   866
apply(subst v4)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   867
apply(auto)[2]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   868
apply(subst (asm) (4) POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   869
apply(subst (asm) v4)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   870
apply(drule_tac x="v2" in meta_spec)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   871
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   872
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   873
apply(auto)[2]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   874
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   875
thm POSIX_ALT_I2
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   876
apply(rule POSIX_ALT_I2)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   877
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   878
apply(rule ccontr)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   879
apply(auto simp add: POSIX_def)[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   880
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   881
apply(rule allI)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   882
apply(rule impI)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   883
apply(erule conjE)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   884
thm POSIX_ALT_I2
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   885
apply(frule POSIX_ALT1a)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   886
apply(drule POSIX_ALT1b)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   887
apply(rule POSIX_ALT_I2)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   888
apply auto[1]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   889
apply(subst v4)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   890
apply(auto)[2]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   891
apply(rotate_tac 1)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   892
apply(drule_tac x="v2" in meta_spec)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   893
apply(simp)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   894
apply(subst (asm) (4) POSIX_def)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   895
apply(subst (asm) v4)
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   896
apply(auto)[2]
c603b27083f3 fahad's experiments
Fahad Ausaf <fahad.ausaf@kcl.ac.uk>
parents:
diff changeset
   897
(* stuck in the ALT case *)