thys/Sulzmann.thy
author Christian Urban <urbanc@in.tum.de>
Wed, 28 Jun 2017 10:37:05 +0100
changeset 255 222ed43892ea
parent 254 7c89d3f6923e
child 256 146b4817aebd
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
   
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
theory Sulzmann
254
7c89d3f6923e polished
Christian Urban <urbanc@in.tum.de>
parents: 248
diff changeset
     3
  imports "Positions" 
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
begin
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
section {* Sulzmann's "Ordering" of Values *}
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
255
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
     9
inductive ValOrd :: "val \<Rightarrow> val \<Rightarrow> bool" ("_ \<prec> _" [100, 100] 100)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    10
where
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    11
  MY0: "length (flat v2) < length (flat v1) \<Longrightarrow> v1 \<prec> v2" 
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    12
| C2: "\<lbrakk>v1 \<prec> v1'; flat (Seq v1 v2) = flat (Seq v1' v2')\<rbrakk> \<Longrightarrow> (Seq v1 v2) \<prec> (Seq v1' v2')" 
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    13
| C1: "\<lbrakk>v2 \<prec> v2'; flat v2 = flat v2'\<rbrakk> \<Longrightarrow> (Seq v1 v2) \<prec> (Seq v1 v2')" 
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    14
| A2: "flat v1 = flat v2 \<Longrightarrow> (Left v1) \<prec> (Right v2)"
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    15
| A3: "\<lbrakk>v2 \<prec> v2'; flat v2 = flat v2'\<rbrakk> \<Longrightarrow> (Right v2) \<prec> (Right v2')"
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    16
| A4: "\<lbrakk>v1 \<prec> v1'; flat v1 = flat v1'\<rbrakk> \<Longrightarrow> (Left v1) \<prec> (Left v1')"
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    17
| K1: "flat (Stars (v#vs)) = [] \<Longrightarrow> (Stars []) \<prec> (Stars (v#vs))"
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    18
| K3: "\<lbrakk>v1 \<prec> v2; flat (Stars (v1#vs1)) = flat (Stars (v2#vs2))\<rbrakk> \<Longrightarrow> (Stars (v1#vs1)) \<prec> (Stars (v2#vs2))"
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    19
| K4: "\<lbrakk>(Stars vs1) \<prec> (Stars vs2); flat (Stars vs1) = flat (Stars vs2)\<rbrakk>  \<Longrightarrow> (Stars (v#vs1)) \<prec> (Stars (v#vs2))"
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    20
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    21
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    22
(*
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    23
inductive ValOrd :: "val \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<preceq>_ _" [100, 100, 100] 100)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    24
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    25
  C2: "v1 \<preceq>r1 v1' \<Longrightarrow> (Seq v1 v2) \<preceq>(SEQ r1 r2) (Seq v1' v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    26
| C1: "v2 \<preceq>r2 v2' \<Longrightarrow> (Seq v1 v2) \<preceq>(SEQ r1 r2) (Seq v1 v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    27
| A1: "length (flat v2) > length (flat v1) \<Longrightarrow> (Right v2) \<preceq>(ALT r1 r2) (Left v1)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    28
| A2: "length (flat v1) \<ge> length (flat v2) \<Longrightarrow> (Left v1) \<preceq>(ALT r1 r2) (Right v2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    29
| A3: "v2 \<preceq>r2 v2' \<Longrightarrow> (Right v2) \<preceq>(ALT r1 r2) (Right v2')"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    30
| A4: "v1 \<preceq>r1 v1' \<Longrightarrow> (Left v1) \<preceq>(ALT r1 r2) (Left v1')"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    31
| K1: "flat (Stars (v # vs)) = [] \<Longrightarrow> (Stars []) \<preceq>(STAR r) (Stars (v # vs))"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    32
| K2: "flat (Stars (v # vs)) \<noteq> [] \<Longrightarrow> (Stars (v # vs)) \<preceq>(STAR r) (Stars [])"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    33
| K3: "v1 \<preceq>r v2 \<Longrightarrow> (Stars (v1 # vs1)) \<preceq>(STAR r) (Stars (v2 # vs2))"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    34
| K4: "(Stars vs1) \<preceq>(STAR r) (Stars vs2) \<Longrightarrow> (Stars (v # vs1)) \<preceq>(STAR r) (Stars (v # vs2))"
255
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    35
*)
248
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    36
(*| MY1: "Void \<preceq>ONE Void" 
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    37
| MY2: "(Char c) \<preceq>(CHAR c) (Char c)" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    38
| MY3: "(Stars []) \<preceq>(STAR r) (Stars [])" 
248
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    39
*)
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    40
248
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    41
(*
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    42
lemma ValOrd_refl: 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    43
  assumes "\<turnstile> v : r" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    44
  shows "v \<preceq>r v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    45
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    46
apply(induct r rule: Prf.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    47
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    48
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    49
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    50
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    51
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    52
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    53
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    54
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    55
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    56
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    57
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    58
done
248
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    59
*)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    60
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    61
lemma ValOrd_irrefl: 
255
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    62
  assumes "\<turnstile> v : r"  "v \<prec> v" 
248
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    63
  shows "False"
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    64
using assms
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    65
apply(induct v r rule: Prf.induct)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    66
apply(erule ValOrd.cases)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    67
apply(simp_all)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    68
apply(erule ValOrd.cases)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    69
apply(simp_all)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    70
apply(erule ValOrd.cases)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    71
apply(simp_all)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    72
apply(erule ValOrd.cases)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    73
apply(simp_all)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    74
apply(erule ValOrd.cases)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    75
apply(simp_all)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    76
apply(erule ValOrd.cases)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    77
apply(simp_all)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    78
apply(erule ValOrd.cases)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    79
apply(simp_all)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    80
done
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    81
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    82
lemma prefix_sprefix:
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    83
  shows "xs \<sqsubseteq>pre ys \<longleftrightarrow> (xs = ys \<or> xs \<sqsubset>spre ys)"
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    84
apply(auto simp add: sprefix_list_def prefix_list_def)
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    85
done
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    86
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    87
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    88
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    89
lemma Posix_CPT2:
255
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    90
  assumes "v1 \<prec> v2" 
248
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    91
  shows "v1 :\<sqsubset>val v2" 
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    92
using assms
255
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    93
apply(induct v1 v2 arbitrary: rule: ValOrd.induct)
254
7c89d3f6923e polished
Christian Urban <urbanc@in.tum.de>
parents: 248
diff changeset
    94
apply(rule val_ord_shorterI)
248
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    95
apply(simp)
254
7c89d3f6923e polished
Christian Urban <urbanc@in.tum.de>
parents: 248
diff changeset
    96
apply(rule val_ord_SeqI1)
248
b90ff5abb437 added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents: 247
diff changeset
    97
apply(simp)
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    98
apply(simp)
255
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
    99
apply(rule val_ord_SeqI2)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   100
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   101
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   102
apply(simp add: val_ord_ex_def)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   103
apply(rule_tac x="[0]" in exI)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   104
apply(auto simp add: val_ord_def Pos_empty pflat_len_simps)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   105
apply(smt inlen_bigger)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   106
apply(rule val_ord_RightI)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   107
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   108
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   109
apply(rule val_ord_LeftI)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   110
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   111
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   112
defer
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   113
apply(rule val_ord_StarsI)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   114
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   115
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   116
apply(rule val_ord_StarsI2)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   117
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   118
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   119
oops
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   120
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   121
lemma Posix_CPT2:
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   122
  assumes "v1 :\<sqsubset>val v2" "v1 \<in> CPTpre r s" "v2 \<in> CPTpre r s"
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   123
  shows "v1 \<prec> v2"
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   124
using assms
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   125
apply(induct r arbitrary: v1 v2 s)  
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   126
apply(auto simp add: CPTpre_def)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   127
apply(erule CPrf.cases)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   128
apply(simp_all)[7]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   129
apply(auto simp add: CPTpre_def)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   130
apply(erule CPrf.cases)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   131
apply(simp_all)[7]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   132
apply(auto simp add: CPTpre_def)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   133
apply(erule CPrf.cases)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   134
apply(simp_all)[7]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   135
apply(simp add: val_ord_ex_def)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   136
apply(auto simp add: val_ord_def)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   137
apply(auto simp add: CPTpre_def)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   138
apply(erule CPrf.cases)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   139
apply(simp_all)[7]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   140
apply(erule CPrf.cases)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   141
apply(simp_all)[7]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   142
apply(auto simp add: val_ord_ex_def val_ord_def)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   143
(* SEQ case *)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   144
apply(subst (asm) (5) CPTpre_def)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   145
apply(subst (asm) (5) CPTpre_def)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   146
apply(auto)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   147
apply(erule CPrf.cases)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   148
apply(simp_all)[7]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   149
apply(erule CPrf.cases)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   150
apply(simp_all)[7]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   151
apply(clarify)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   152
apply(drule val_ord_SeqE)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   153
apply(erule disjE)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   154
apply(drule_tac x="v1a" in meta_spec)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   155
apply(rotate_tac 7)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   156
apply(drule_tac x="v1b" in meta_spec)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   157
apply(drule_tac x="flat v1a @ flat v2a @ s'" in meta_spec)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   158
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   159
apply(drule meta_mp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   160
apply(auto simp add: CPTpre_def)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   161
apply(drule meta_mp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   162
apply(auto simp add: CPTpre_def)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   163
apply(rule ValOrd.intros)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   164
apply(subst (asm) (3) CPTpre_def)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   165
apply(subst (asm) (3) CPTpre_def)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   166
apply(auto)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   167
apply(drule_tac meta_mp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   168
apply(auto simp add: CPTpre_def)[1]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   169
apply(erule CPrf.cases)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   170
apply(simp_all)[7]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   171
apply(erule CPrf.cases)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   172
apply(simp_all)[7]
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   173
apply(clarify)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   174
apply(drule val_ord_SeqE)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   175
apply(erule disjE)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   176
apply(simp add: append_eq_append_conv2)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   177
apply(auto)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   178
prefer 2
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   179
apply(rule  ValOrd.intros(2))
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   180
prefer 2
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   181
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   182
thm ValOrd.intros
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   183
apply(case_tac "flat v1b = flat v1a")
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   184
apply(rule ValOrd.intros)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   185
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   186
apply(simp)
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   187
222ed43892ea updated
Christian Urban <urbanc@in.tum.de>
parents: 254
diff changeset
   188
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   189
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   190
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   191
lemma Posix_CPT:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   192
  assumes "v1 :\<sqsubset>val v2" "v1 \<in> CPT r s" "v2 \<in> CPT r s"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   193
  shows "v1 \<preceq>r v2" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   194
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   195
apply(induct r arbitrary: v1 v2 s rule: rexp.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   196
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   197
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   198
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   199
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   200
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   201
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   202
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   203
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   204
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   205
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   206
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   207
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   208
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   209
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   210
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   211
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   212
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   213
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   214
(*SEQ case *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   215
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   216
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   217
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   218
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   219
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   220
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   221
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   222
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   223
thm val_ord_SEQ
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   224
apply(drule_tac r="r1a" in  val_ord_SEQ)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   225
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   226
using Prf_CPrf apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   227
using Prf_CPrf apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   228
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   229
apply(rule C2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   230
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   231
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   232
apply(rule C1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   233
apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   234
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   235
apply(simp add: append_eq_append_conv2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   236
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   237
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   238
apply(drule_tac x="v1a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   239
apply(rotate_tac 8)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   240
apply(drule_tac x="v1b" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   241
apply(rotate_tac 8)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   242
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   243
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   244
(* HERE *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   245
apply(subst (asm) (3) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   246
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   247
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   248
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   249
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   250
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   251
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   252
apply(simp add: val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   253
oops
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   254
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   255
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   256
lemma ValOrd_trans:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   257
  assumes "x \<preceq>r y" "y \<preceq>r z"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   258
  and "x \<in> CPT r s" "y \<in> CPT r s" "z \<in> CPT r s"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   259
  shows "x \<preceq>r z"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   260
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   261
apply(induct x r y arbitrary: s z rule: ValOrd.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   262
apply(rotate_tac 2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   263
apply(erule ValOrd.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   264
apply(simp_all)[13]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   265
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   266
apply(drule_tac x="s" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   267
apply(drule_tac x="v1'a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   268
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   269
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   270
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   271
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   272
oops
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   273
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   274
lemma ValOrd_preorder:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   275
  "preorder_on (CPT r s) {(v1, v2). v1 \<preceq>r v2 \<and> v1 \<in> (CPT r s) \<and> v2 \<in> (CPT r s)}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   276
apply(simp add: preorder_on_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   277
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   278
apply(simp add: refl_on_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   279
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   280
apply(rule ValOrd_refl)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   281
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   282
apply(rule Prf_CPrf)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   283
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   284
apply(simp add: trans_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   285
apply(auto)
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   286
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   287
definition ValOrdEq :: "val \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<ge>_ _" [100, 100, 100] 100)
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   288
where 
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
  "v\<^sub>1 \<ge>r v\<^sub>2 \<equiv> v\<^sub>1 = v\<^sub>2 \<or> (v\<^sub>1 >r v\<^sub>2 \<and> flat v\<^sub>1 = flat v\<^sub>2)"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   291
(*
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   292
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   293
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   294
inductive ValOrd :: "val \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<succ>_ _" [100, 100, 100] 100)
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   295
where
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   296
  "v2 \<succ>r2 v2' \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1 v2')" 
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   297
| "\<lbrakk>v1 \<succ>r1 v1'; v1 \<noteq> v1'\<rbrakk> \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1' v2')" 
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   298
| "length (flat v1) \<ge> length (flat v2) \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Right v2)"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   299
| "length (flat v2) > length (flat v1) \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Left v1)"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   300
| "v2 \<succ>r2 v2' \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Right v2')"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   301
| "v1 \<succ>r1 v1' \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Left v1')"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   302
| "Void \<succ>EMPTY Void"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   303
| "(Char c) \<succ>(CHAR c) (Char c)"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   304
| "flat (Stars (v # vs)) = [] \<Longrightarrow> (Stars []) \<succ>(STAR r) (Stars (v # vs))"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   305
| "flat (Stars (v # vs)) \<noteq> [] \<Longrightarrow> (Stars (v # vs)) \<succ>(STAR r) (Stars [])"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   306
| "\<lbrakk>v1 \<succ>r v2; v1 \<noteq> v2\<rbrakk> \<Longrightarrow> (Stars (v1 # vs1)) \<succ>(STAR r) (Stars (v2 # vs2))"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   307
| "(Stars vs1) \<succ>(STAR r) (Stars vs2) \<Longrightarrow> (Stars (v # vs1)) \<succ>(STAR r) (Stars (v # vs2))"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   308
| "(Stars []) \<succ>(STAR r) (Stars [])"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   309
*)
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   310
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   311
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   312
section {* Bit-Encodings *}
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   313
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   314
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   315
fun 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   316
  code :: "val \<Rightarrow> rexp \<Rightarrow> bool list"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   317
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   318
  "code Void ONE = []"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   319
| "code (Char c) (CHAR d) = []"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   320
| "code (Left v) (ALT r1 r2) = False # (code v r1)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   321
| "code (Right v) (ALT r1 r2) = True # (code v r2)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   322
| "code (Seq v1 v2) (SEQ r1 r2) = (code v1 r1) @ (code v2 r2)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   323
| "code (Stars []) (STAR r) = [True]"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   324
| "code (Stars (v # vs)) (STAR r) =  False # (code v r) @ code (Stars vs) (STAR r)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   325
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   326
fun 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   327
  Stars_add :: "val \<Rightarrow> val \<Rightarrow> val"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   328
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   329
  "Stars_add v (Stars vs) = Stars (v # vs)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   330
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   331
function
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   332
  decode' :: "bool list \<Rightarrow> rexp \<Rightarrow> (val * bool list)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   333
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   334
  "decode' ds ZERO = (Void, [])"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   335
| "decode' ds ONE = (Void, ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   336
| "decode' ds (CHAR d) = (Char d, ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   337
| "decode' [] (ALT r1 r2) = (Void, [])"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   338
| "decode' (False # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r1 in (Left v, ds'))"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   339
| "decode' (True # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r2 in (Right v, ds'))"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   340
| "decode' ds (SEQ r1 r2) = (let (v1, ds') = decode' ds r1 in
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   341
                             let (v2, ds'') = decode' ds' r2 in (Seq v1 v2, ds''))"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   342
| "decode' [] (STAR r) = (Void, [])"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   343
| "decode' (True # ds) (STAR r) = (Stars [], ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   344
| "decode' (False # ds) (STAR r) = (let (v, ds') = decode' ds r in
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   345
                                    let (vs, ds'') = decode' ds' (STAR r) 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   346
                                    in (Stars_add v vs, ds''))"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   347
by pat_completeness auto
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   348
204
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
   349
termination
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
   350
apply(size_change)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
   351
oops
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
   352
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   353
term "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   354
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   355
lemma decode'_smaller:
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   356
  assumes "decode'_dom (ds, r)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   357
  shows "length (snd (decode' ds r)) \<le> length ds"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   358
using assms
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   359
apply(induct ds r)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   360
apply(auto simp add: decode'.psimps split: prod.split)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   361
using dual_order.trans apply blast
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   362
by (meson dual_order.trans le_SucI)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   363
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   364
termination "decode'"  
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   365
apply(relation "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))") 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   366
apply(auto dest!: decode'_smaller)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   367
by (metis less_Suc_eq_le snd_conv)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   368
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   369
fun 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   370
  decode :: "bool list \<Rightarrow> rexp \<Rightarrow> val option"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   371
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   372
  "decode ds r = (let (v, ds') = decode' ds r 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   373
                  in (if ds' = [] then Some v else None))"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   374
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   375
lemma decode'_code:
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   376
  assumes "\<turnstile> v : r"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   377
  shows "decode' ((code v r) @ ds) r = (v, ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   378
using assms
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   379
by (induct v r arbitrary: ds) (auto)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   380
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   381
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   382
lemma decode_code:
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   383
  assumes "\<turnstile> v : r"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   384
  shows "decode (code v r) r = Some v"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   385
using assms decode'_code[of _ _ "[]"]
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   386
by auto
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
   387
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   388
datatype arexp =
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   389
  AZERO
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   390
| AONE "bool list"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   391
| ACHAR "bool list" char
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   392
| ASEQ "bool list" arexp arexp
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   393
| AALT "bool list" arexp arexp
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   394
| ASTAR "bool list" arexp
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   395
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   396
fun fuse :: "bool list \<Rightarrow> arexp \<Rightarrow> arexp" where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   397
  "fuse bs AZERO = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   398
| "fuse bs (AONE cs) = AONE (bs @ cs)" 
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   399
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   400
| "fuse bs (AALT cs r1 r2) = AALT (bs @ cs) r1 r2"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   401
| "fuse bs (ASEQ cs r1 r2) = ASEQ (bs @ cs) r1 r2"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   402
| "fuse bs (ASTAR cs r) = ASTAR (bs @ cs) r"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   403
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   404
fun internalise :: "rexp \<Rightarrow> arexp" where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   405
  "internalise ZERO = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   406
| "internalise ONE = AONE []"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   407
| "internalise (CHAR c) = ACHAR [] c"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   408
| "internalise (ALT r1 r2) = AALT [] (fuse [False] (internalise r1)) 
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   409
                                     (fuse [True]  (internalise r2))"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   410
| "internalise (SEQ r1 r2) = ASEQ [] (internalise r1) (internalise r2)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   411
| "internalise (STAR r) = ASTAR [] (internalise r)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   412
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   413
fun retrieve :: "arexp \<Rightarrow> val \<Rightarrow> bool list" where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   414
  "retrieve (AONE bs) Void = bs"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   415
| "retrieve (ACHAR bs c) (Char d) = bs"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   416
| "retrieve (AALT bs r1 r2) (Left v) = bs @ retrieve r1 v"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   417
| "retrieve (AALT bs r1 r2) (Right v) = bs @ retrieve r2 v"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   418
| "retrieve (ASEQ bs r1 r2) (Seq v1 v2) = bs @ retrieve r1 v1 @ retrieve r2 v2"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   419
| "retrieve (ASTAR bs r) (Stars []) = bs @ [True]"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   420
| "retrieve (ASTAR bs r) (Stars (v#vs)) = 
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   421
     bs @ [False] @ retrieve r v @ retrieve (ASTAR [] r) (Stars vs)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   422
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   423
fun
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   424
 anullable :: "arexp \<Rightarrow> bool"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   425
where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   426
  "anullable (AZERO) = False"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   427
| "anullable (AONE bs) = True"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   428
| "anullable (ACHAR bs c) = False"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   429
| "anullable (AALT bs r1 r2) = (anullable r1 \<or> anullable r2)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   430
| "anullable (ASEQ bs r1 r2) = (anullable r1 \<and> anullable r2)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   431
| "anullable (ASTAR bs r) = True"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   432
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   433
fun 
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   434
  amkeps :: "arexp \<Rightarrow> bool list"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   435
where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   436
  "amkeps(AONE bs) = bs"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   437
| "amkeps(ASEQ bs r1 r2) = bs @ (amkeps r1) @ (amkeps r2)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   438
| "amkeps(AALT bs r1 r2) = (if anullable(r1) then bs @ (amkeps r1) else bs @ (amkeps r2))"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   439
| "amkeps(ASTAR bs r) = bs @ [True]"
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   440
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   441
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   442
fun
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   443
 ader :: "char \<Rightarrow> arexp \<Rightarrow> arexp"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   444
where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   445
  "ader c (AZERO) = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   446
| "ader c (AONE bs) = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   447
| "ader c (ACHAR bs d) = (if c = d then AONE bs else AZERO)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   448
| "ader c (AALT bs r1 r2) = AALT bs (ader c r1) (ader c r2)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   449
| "ader c (ASEQ bs r1 r2) = 
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   450
     (if anullable r1
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   451
      then AALT bs (ASEQ [] (ader c r1) r2) (fuse (amkeps r1) (ader c r2))
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   452
      else ASEQ bs (ader c r1) r2)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   453
| "ader c (ASTAR bs r) = ASEQ bs (fuse [False] (ader c r)) (ASTAR [] r)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   454
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   455
lemma
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   456
  assumes "\<turnstile> v : der c r"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   457
  shows "Some (injval r c v) = decode (retrieve (ader c (internalise r)) v) r"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   458
using assms
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   459
apply(induct c r arbitrary: v rule: der.induct)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   460
apply(simp_all)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   461
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   462
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   463
apply(case_tac "c = d")
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   464
apply(simp)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   465
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   466
apply(simp)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   467
apply(simp)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   468
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   469
apply(auto split: prod.splits)[1]
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   470
oops
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   471
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   472
end