thys/Sulzmann.thy
author Christian Urban <urbanc@in.tum.de>
Fri, 23 Jun 2017 00:27:53 +0100
changeset 245 b16702bb6242
parent 204 cd9e40280784
child 246 23657fad2017
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
204
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
     3
  imports "Lexer" "~~/src/HOL/Library/Multiset"
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
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
     9
fun 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    10
  size :: "val \<Rightarrow> nat"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    11
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    12
  "size (Void) = 0"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    13
| "size (Char c) = 0"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    14
| "size (Left v) = 1 + size v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    15
| "size (Right v) = 1 + size v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    16
| "size (Seq v1 v2) = 1 + (size v1) + (size v2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    17
| "size (Stars []) = 0"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    18
| "size (Stars (v#vs)) = 1 + (size v) + (size (Stars vs))" 
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    20
lemma Star_size [simp]:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    21
  "\<lbrakk>n < length vs; 0 < length vs\<rbrakk> \<Longrightarrow> size (nth vs n) < size (Stars vs)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    22
apply(induct vs arbitrary: n)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    23
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    24
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    25
by (metis One_nat_def Suc_pred less_Suc0 less_Suc_eq list.size(3) not_add_less1 not_less_eq nth_Cons' trans_less_add2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    26
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    27
lemma Star_size0 [simp]:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    28
  "0 < length vs \<Longrightarrow> 0 < size (Stars vs)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    29
apply(induct vs)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    30
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    31
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    32
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    33
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    34
fun 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    35
  at :: "val \<Rightarrow> nat list \<Rightarrow> val"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    36
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    37
  "at v [] = v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    38
| "at (Left v) (0#ps)= at v ps"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    39
| "at (Right v) (Suc 0#ps)= at v ps"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    40
| "at (Seq v1 v2) (0#ps)= at v1 ps"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    41
| "at (Seq v1 v2) (Suc 0#ps)= at v2 ps"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    42
| "at (Stars vs) (n#ps)= at (nth vs n) ps"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    43
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    44
fun 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    45
  ato :: "val \<Rightarrow> nat list \<Rightarrow> val option"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    46
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    47
  "ato v [] = Some v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    48
| "ato (Left v) (0#ps)= ato v ps"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    49
| "ato (Right v) (Suc 0#ps)= ato v ps"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    50
| "ato (Seq v1 v2) (0#ps)= ato v1 ps"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    51
| "ato (Seq v1 v2) (Suc 0#ps)= ato v2 ps"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    52
| "ato (Stars vs) (n#ps)= (if (n < length vs) then ato (nth vs n) ps else None)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    53
| "ato v p = None"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    54
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    55
fun Pos :: "val \<Rightarrow> (nat list) set"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    56
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    57
  "Pos (Void) = {[]}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    58
| "Pos (Char c) = {[]}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    59
| "Pos (Left v) = {[]} \<union> {0#ps | ps. ps \<in> Pos v}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    60
| "Pos (Right v) = {[]} \<union> {1#ps | ps. ps \<in> Pos v}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    61
| "Pos (Seq v1 v2) = {[]} \<union> {0#ps | ps. ps \<in> Pos v1} \<union> {1#ps | ps. ps \<in> Pos v2}" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    62
| "Pos (Stars []) = {[]}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    63
| "Pos (Stars (v#vs)) = {[]} \<union> {0#ps | ps. ps \<in> Pos v} \<union> {(Suc n)#ps | n ps. n#ps \<in> Pos (Stars vs)}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    64
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    65
lemma Pos_empty:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    66
  shows "[] \<in> Pos v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    67
apply(induct v rule: Pos.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    68
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    69
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    70
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    71
lemma Pos_finite_aux:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    72
  assumes "\<forall>v \<in> set vs. finite (Pos v)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    73
  shows "finite (Pos (Stars vs))"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    74
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    75
apply(induct vs)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    76
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    77
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    78
apply(subgoal_tac "finite (Pos (Stars vs) - {[]})")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    79
apply(rule_tac f="\<lambda>l. Suc (hd l) # tl l" in finite_surj)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    80
apply(assumption)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    81
back
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    82
apply(auto simp add: image_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    83
apply(rule_tac x="n#ps" in bexI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    84
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    85
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    86
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    87
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    88
lemma Pos_finite:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    89
  shows "finite (Pos v)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    90
apply(induct v rule: val.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    91
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    92
apply(simp add: Pos_finite_aux)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    93
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    94
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    95
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    96
lemma ato_test:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    97
  assumes "p \<in> Pos v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    98
  shows "\<exists>v'. ato v p = Some v'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
    99
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   100
apply(induct v arbitrary: p rule: Pos.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   101
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   102
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   103
by (metis ato.simps(6) option.distinct(1))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   104
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   105
definition pflat :: "val \<Rightarrow> nat list => string option"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   106
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   107
  "pflat v p \<equiv> (if p \<in> Pos v then Some (flat (at v p)) else None)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   108
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   109
fun intlen :: "'a list \<Rightarrow> int"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   110
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   111
  "intlen [] = 0"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   112
| "intlen (x#xs) = 1 + intlen xs"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   113
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   114
lemma inlen_bigger:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   115
  shows "0 \<le> intlen xs"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   116
apply(induct xs)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   117
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   118
done 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   119
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   120
lemma intlen_append:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   121
  shows "intlen (xs @ ys) = intlen xs + intlen ys"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   122
apply(induct xs arbitrary: ys)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   123
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   124
done 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   125
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   126
lemma intlen_length:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   127
  assumes "length xs < length ys"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   128
  shows "intlen xs < intlen ys"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   129
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   130
apply(induct xs arbitrary: ys)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   131
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   132
apply(case_tac ys)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   133
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   134
apply (smt inlen_bigger)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   135
by (smt Suc_lessE intlen.simps(2) length_Suc_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   136
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   137
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   138
definition pflat_len :: "val \<Rightarrow> nat list => int"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   139
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   140
  "pflat_len v p \<equiv> (if p \<in> Pos v then intlen (flat (at v p)) else -1)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   141
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   142
lemma pflat_len_simps:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   143
  shows "pflat_len (Seq v1 v2) (0#p) = pflat_len v1 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   144
  and   "pflat_len (Seq v1 v2) (Suc 0#p) = pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   145
  and   "pflat_len (Left v) (0#p) = pflat_len v p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   146
  and   "pflat_len (Left v) (Suc 0#p) = -1"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   147
  and   "pflat_len (Right v) (Suc 0#p) = pflat_len v p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   148
  and   "pflat_len (Right v) (0#p) = -1"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   149
  and   "pflat_len v [] = intlen (flat v)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   150
apply(auto simp add: pflat_len_def Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   151
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   152
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   153
lemma pflat_len_Stars_simps:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   154
  assumes "n < length vs"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   155
  shows "pflat_len (Stars vs) (n#p) = pflat_len (vs!n) p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   156
using assms 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   157
apply(induct vs arbitrary: n p)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   158
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   159
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   160
apply(simp add: pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   161
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   162
apply (metis at.simps(6))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   163
apply (metis Suc_less_eq Suc_pred)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   164
by (metis diff_Suc_1 less_Suc_eq_0_disj nth_Cons')
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   165
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   166
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   167
lemma Two_to_Three_aux:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   168
  assumes "p \<in> Pos v1 \<union> Pos v2" "pflat_len v1 p = pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   169
  shows "p \<in> Pos v1 \<inter> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   170
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   171
apply(simp add: pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   172
apply(auto split: if_splits)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   173
apply (smt inlen_bigger)+
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   174
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   175
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   176
lemma Two_to_Three:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   177
  assumes "\<forall>p \<in> Pos v1 \<union> Pos v2. pflat v1 p = pflat v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   178
  shows "Pos v1 = Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   179
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   180
by (metis Un_iff option.distinct(1) pflat_def subsetI subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   181
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   182
lemma Two_to_Three_orig:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   183
  assumes "\<forall>p \<in> Pos v1 \<union> Pos v2. pflat_len v1 p = pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   184
  shows "Pos v1 = Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   185
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   186
by (metis Un_iff inlen_bigger neg_0_le_iff_le not_one_le_zero pflat_len_def subsetI subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   187
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   188
lemma set_eq1:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   189
  assumes "insert [] A = insert [] B" "[] \<notin> A"  "[] \<notin> B"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   190
  shows "A = B"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   191
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   192
by (simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   193
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   194
lemma set_eq2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   195
  assumes "A \<union> B = A \<union> C"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   196
  and "A \<inter> B = {}" "A \<inter> C = {}"  
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   197
  shows "B = C"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   198
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   199
using Un_Int_distrib sup_bot.left_neutral sup_commute by blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   200
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   201
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   202
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   203
lemma Three_to_One:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   204
  assumes "\<turnstile> v1 : r" "\<turnstile> v2 : r" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   205
  and "Pos v1 = Pos v2" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   206
  shows "v1 = v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   207
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   208
apply(induct v1 arbitrary: r v2 rule: Pos.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   209
apply(erule Prf.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 Prf.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(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   214
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   215
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   216
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   217
apply(erule Prf.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(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   220
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   221
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   222
apply(simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   223
apply(drule_tac x="r1a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   224
apply(drule_tac x="v1a" in meta_spec)
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
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   227
thm subset_antisym
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   228
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   229
apply(auto)[3]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   230
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   231
apply(simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   232
using Pos_empty apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   233
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   234
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   235
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   236
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   237
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   238
apply(simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   239
using Pos_empty apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   240
apply(simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   241
apply(drule_tac x="r2a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   242
apply(drule_tac x="v2b" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   243
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   244
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   245
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   246
apply(auto)[3]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   247
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   248
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   249
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   250
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   251
apply(simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   252
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   253
apply(drule_tac x="r1a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   254
apply(drule_tac x="r2a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   255
apply(drule_tac x="v1b" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   256
apply(drule_tac x="v2c" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   257
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   258
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   259
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   260
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   261
apply(subgoal_tac "0 # x \<in> {0 # ps |ps. ps \<in> Pos v1a}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   262
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   263
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   264
apply(subgoal_tac "0 # x \<in> {0 # ps |ps. ps \<in> Pos v1b}  \<union> {Suc 0 # ps |ps. ps \<in> Pos v2c}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   265
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   266
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   267
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   268
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   269
apply(subgoal_tac "0 # x \<in> {0 # ps |ps. ps \<in> Pos v1b}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   270
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   271
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   272
apply(subgoal_tac "0 # x \<in> {0 # ps |ps. ps \<in> Pos v1a}  \<union> {Suc 0 # ps |ps. ps \<in> Pos v2b}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   273
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   274
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   275
apply(simp (no_asm_use))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   276
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   277
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   278
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   279
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   280
apply(subgoal_tac "Suc 0 # x \<in> {Suc 0 # ps |ps. ps \<in> Pos v2b}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   281
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   282
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   283
apply(subgoal_tac "Suc 0 # x \<in> {0 # ps |ps. ps \<in> Pos v1b}  \<union> {Suc 0 # ps |ps. ps \<in> Pos v2c}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   284
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   285
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   286
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   287
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   288
apply(subgoal_tac "Suc 0 # x \<in> {Suc 0 # ps |ps. ps \<in> Pos v2c}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   289
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   290
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   291
apply(subgoal_tac "Suc 0 # x \<in> {0 # ps |ps. ps \<in> Pos v1b}  \<union> {Suc 0 # ps |ps. ps \<in> Pos v2b}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   292
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   293
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   294
apply(simp (no_asm_use))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   295
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   296
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   297
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   298
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   299
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   300
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   301
using Pos_empty apply fastforce
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   302
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   303
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   304
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   305
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   306
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   307
using Pos_empty apply fastforce
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   308
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   309
apply(simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   310
apply(drule_tac x="rb" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   311
apply(drule_tac x="STAR rb" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   312
apply(drule_tac x="vb" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   313
apply(drule_tac x="Stars vsb" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   314
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   315
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   316
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   317
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   318
apply(subgoal_tac "0 # x \<in> {0 # ps |ps. ps \<in> Pos va}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   319
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   320
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   321
apply(subgoal_tac "0 # x \<in> {0 # ps |ps. ps \<in> Pos vb} \<union> {Suc n # ps |n ps. n # ps \<in> Pos (Stars vsb)}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   322
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   323
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   324
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   325
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   326
apply(subgoal_tac "0 # x \<in> {0 # ps |ps. ps \<in> Pos vb}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   327
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   328
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   329
apply(subgoal_tac "0 # x \<in> {0 # ps |ps. ps \<in> Pos va} \<union> {Suc n # ps |n ps. n # ps \<in> Pos (Stars vsa)}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   330
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   331
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   332
apply(simp (no_asm_use))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   333
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   334
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   335
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   336
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   337
apply(case_tac vsa)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   338
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   339
apply (simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   340
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   341
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   342
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   343
apply (simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   344
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   345
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   346
apply(subgoal_tac 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   347
  "Suc 0 # ps \<in> {Suc n # ps |n ps. n = 0 \<and> ps \<in> Pos a \<or> (\<exists>na. n = Suc na \<and> na # ps \<in> Pos (Stars list))}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   348
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   349
apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   350
apply(subgoal_tac "Suc 0 # ps \<in> {0 # ps |ps. ps \<in> Pos vb} \<union>  {Suc n # ps |n ps. n # ps \<in> Pos (Stars vsb)}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   351
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   352
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   353
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   354
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   355
apply(subgoal_tac 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   356
  "Suc (Suc n) # ps \<in> {Suc n # ps |n ps. n = 0 \<and> ps \<in> Pos a \<or> (\<exists>na. n = Suc na \<and> na # ps \<in> Pos (Stars list))}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   357
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   358
apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   359
apply(subgoal_tac "Suc (Suc n) # ps \<in> {0 # ps |ps. ps \<in> Pos vb} \<union> {Suc n # ps |n ps. n # ps \<in> Pos (Stars vsb)}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   360
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   361
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   362
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   363
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   364
apply(case_tac vsb)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   365
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   366
apply (simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   367
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   368
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   369
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   370
apply (simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   371
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   372
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   373
apply(subgoal_tac 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   374
  "Suc 0 # ps \<in> {Suc n # ps |n ps. n = 0 \<and> ps \<in> Pos a \<or> (\<exists>na. n = Suc na \<and> na # ps \<in> Pos (Stars list))}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   375
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   376
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   377
apply(subgoal_tac "Suc 0 # ps \<in> {Suc n # ps |n ps. n # ps \<in> Pos (Stars vsa)}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   378
apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   379
using list.inject apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   380
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   381
apply(subgoal_tac 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   382
  "Suc (Suc n) # ps \<in> {Suc n # ps |n ps. n = 0 \<and> ps \<in> Pos a \<or> (\<exists>na. n = Suc na \<and> na # ps \<in> Pos (Stars list))}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   383
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   384
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   385
apply(subgoal_tac "Suc (Suc n) # ps \<in> {0 # ps |ps. ps \<in> Pos vb} \<union> {Suc n # ps |n ps. n # ps \<in> Pos (Stars vsa)}")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   386
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   387
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   388
apply(simp (no_asm_use))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   389
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   390
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   391
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   392
definition prefix_list:: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<sqsubseteq>pre _")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   393
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   394
  "ps1 \<sqsubseteq>pre ps2 \<equiv> (\<exists>ps'. ps1 @ps' = ps2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   395
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   396
definition sprefix_list:: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<sqsubset>spre _")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   397
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   398
  "ps1 \<sqsubset>spre ps2 \<equiv> (ps1 \<sqsubseteq>pre ps2 \<and> ps1 \<noteq> ps2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   399
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   400
inductive lex_lists :: "nat list \<Rightarrow> nat list \<Rightarrow> bool" ("_ \<sqsubset>lex _")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   401
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   402
  "[] \<sqsubset>lex p#ps"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   403
| "ps1 \<sqsubset>lex ps2 \<Longrightarrow> (p#ps1) \<sqsubset>lex (p#ps2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   404
| "p1 < p2 \<Longrightarrow> (p1#ps1) \<sqsubset>lex (p2#ps2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   405
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   406
lemma lex_irrfl:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   407
  fixes ps1 ps2 :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   408
  assumes "ps1 \<sqsubset>lex ps2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   409
  shows "ps1 \<noteq> ps2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   410
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   411
apply(induct rule: lex_lists.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   412
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   413
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   414
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   415
lemma lex_append:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   416
  assumes "ps2 \<noteq> []"  
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   417
  shows "ps \<sqsubset>lex ps @ ps2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   418
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   419
apply(induct ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   420
apply(auto intro: lex_lists.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   421
apply(case_tac ps2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   422
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   423
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   424
apply(auto intro: lex_lists.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   425
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   426
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   427
lemma lexordp_simps [simp]:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   428
  fixes xs ys :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   429
  shows "[] \<sqsubset>lex ys = (ys \<noteq> [])"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   430
  and   "xs \<sqsubset>lex [] = False"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   431
  and   "(x # xs) \<sqsubset>lex (y # ys) \<longleftrightarrow> (x < y \<or> (\<not> y < x \<and> xs \<sqsubset>lex ys))"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   432
apply -
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   433
apply (metis lex_append lex_lists.simps list.simps(3))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   434
using lex_lists.cases apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   435
using lex_lists.cases lex_lists.intros(2) lex_lists.intros(3) not_less_iff_gr_or_eq by fastforce
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   436
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   437
lemma lex_append_cancel [simp]:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   438
  fixes ps ps1 ps2 :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   439
  shows "ps @ ps1 \<sqsubset>lex ps @ ps2 \<longleftrightarrow> ps1 \<sqsubset>lex ps2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   440
apply(induct ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   441
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   442
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   443
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   444
lemma lex_trans:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   445
  fixes ps1 ps2 ps3 :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   446
  assumes "ps1 \<sqsubset>lex ps2" "ps2 \<sqsubset>lex ps3"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   447
  shows "ps1 \<sqsubset>lex ps3"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   448
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   449
apply(induct arbitrary: ps3 rule: lex_lists.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   450
apply(erule lex_lists.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   451
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   452
apply(rotate_tac 2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   453
apply(erule lex_lists.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   454
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   455
apply(erule lex_lists.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   456
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   457
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   458
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   459
lemma trichotomous_aux:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   460
  fixes p q :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   461
  assumes "p \<sqsubset>lex q" "p \<noteq> q"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   462
  shows "\<not>(q \<sqsubset>lex p)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   463
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   464
apply(induct rule: lex_lists.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   465
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   466
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   467
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   468
lemma trichotomous_aux2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   469
  fixes p q :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   470
  assumes "p \<sqsubset>lex q" "q \<sqsubset>lex p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   471
  shows "False"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   472
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   473
apply(induct rule: lex_lists.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   474
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   475
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   476
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   477
lemma trichotomous:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   478
  fixes p q :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   479
  shows "p = q \<or> p \<sqsubset>lex q \<or> q \<sqsubset>lex p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   480
apply(induct p arbitrary: q)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   481
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   482
apply(case_tac q)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   483
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   484
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   485
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   486
definition dpos :: "val \<Rightarrow> val \<Rightarrow> nat list \<Rightarrow> bool" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   487
  where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   488
  "dpos v1 v2 p \<equiv> (p \<in> Pos v1 \<union> Pos v2) \<and> (p \<notin> Pos v1 \<inter> Pos v2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   489
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   490
definition
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   491
  "DPos v1 v2 \<equiv> {p. dpos v1 v2 p}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   492
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   493
lemma outside_lemma:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   494
  assumes "p \<notin> Pos v1 \<union> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   495
  shows "pflat_len v1 p = pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   496
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   497
apply(auto simp add: pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   498
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   499
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   500
lemma dpos_lemma_aux:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   501
  assumes "p \<in> Pos v1 \<union> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   502
  and "pflat_len v1 p = pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   503
  shows "p \<in> Pos v1 \<inter> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   504
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   505
apply(auto simp add: pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   506
apply (smt inlen_bigger)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   507
apply (smt inlen_bigger)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   508
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   509
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   510
lemma dpos_lemma:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   511
  assumes "p \<in> Pos v1 \<union> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   512
  and "pflat_len v1 p = pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   513
  shows "\<not>dpos v1 v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   514
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   515
apply(auto simp add: dpos_def dpos_lemma_aux)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   516
using dpos_lemma_aux apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   517
using dpos_lemma_aux apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   518
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   519
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   520
lemma dpos_lemma2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   521
  assumes "p \<in> Pos v1 \<union> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   522
  and "dpos v1 v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   523
  shows "pflat_len v1 p \<noteq> pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   524
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   525
using dpos_lemma by blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   526
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   527
lemma DPos_lemma:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   528
  assumes "p \<in> DPos v1 v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   529
  shows "pflat_len v1 p \<noteq> pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   530
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   531
unfolding DPos_def 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   532
apply(auto simp add: pflat_len_def dpos_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   533
apply (smt inlen_bigger)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   534
by (smt inlen_bigger)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   535
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   536
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   537
definition val_ord:: "val \<Rightarrow> nat list \<Rightarrow> val \<Rightarrow> bool" ("_ \<sqsubset>val _ _")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   538
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   539
  "v1 \<sqsubset>val p v2 \<equiv> (p \<in> Pos v1 \<and> pflat_len v1 p > pflat_len v2 p \<and>
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   540
                   (\<forall>q \<in> Pos v1 \<union> Pos v2. q \<sqsubset>lex p \<longrightarrow> pflat_len v1 q = pflat_len v2 q))"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   541
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   542
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   543
definition val_ord_ex:: "val \<Rightarrow> val \<Rightarrow> bool" ("_ :\<sqsubset>val _")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   544
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   545
  "v1 :\<sqsubset>val v2 \<equiv> (\<exists>p. v1 \<sqsubset>val p v2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   546
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   547
definition val_ord_ex1:: "val \<Rightarrow> val \<Rightarrow> bool" ("_ :\<sqsubseteq>val _")
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   548
where
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   549
  "v1 :\<sqsubseteq>val v2 \<equiv> v1 :\<sqsubset>val v2 \<or> v1 = v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   550
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   551
lemma val_ord_shorterI:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   552
  assumes "length (flat v') < length (flat v)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   553
  shows "v :\<sqsubset>val v'" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   554
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   555
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   556
apply(rule_tac x="[]" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   557
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   558
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   559
apply (simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   560
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   561
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   562
apply (simp add: intlen_length)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   563
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   564
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   565
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   566
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   567
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   568
lemma val_ord_ALTI:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   569
  assumes "v \<sqsubset>val p v'" "flat v = flat v'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   570
  shows "(Left v) \<sqsubset>val (0#p) (Left v')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   571
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   572
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   573
apply(erule conjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   574
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   575
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   576
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   577
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   578
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   579
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   580
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   581
apply(simp only: Pos.simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   582
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   583
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   584
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   585
apply(auto simp add: pflat_len_simps)[2]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   586
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   587
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   588
lemma val_ord_ALTI2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   589
  assumes "v \<sqsubset>val p v'" "flat v = flat v'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   590
  shows "(Right v) \<sqsubset>val (1#p) (Right v')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   591
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   592
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   593
apply(erule conjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   594
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   595
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   596
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   597
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   598
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   599
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   600
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   601
apply(simp only: Pos.simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   602
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   603
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   604
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   605
apply(auto simp add: pflat_len_simps)[2]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   606
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   607
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   608
lemma val_ord_STARI:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   609
  assumes "v1 \<sqsubset>val p v2" "flat (Stars (v1#vs1)) = flat (Stars (v2#vs2))"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   610
  shows "(Stars (v1#vs1)) \<sqsubset>val (0#p) (Stars (v2#vs2))" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   611
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   612
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   613
apply(erule conjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   614
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   615
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   616
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   617
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   618
apply(subst pflat_len_Stars_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   619
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   620
apply(subst pflat_len_Stars_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   621
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   622
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   623
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   624
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   625
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   626
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   627
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   628
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   629
apply(auto simp add: pflat_len_Stars_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   630
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   631
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   632
lemma val_ord_STARI2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   633
  assumes "(Stars vs1) \<sqsubset>val n#p (Stars vs2)" "flat (Stars vs1) = flat (Stars vs2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   634
  shows "(Stars (v#vs1)) \<sqsubset>val (Suc n#p) (Stars (v#vs2))" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   635
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   636
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   637
apply(erule conjE)+
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   638
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   639
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   640
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   641
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   642
apply(case_tac vs1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   643
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   644
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   645
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   646
apply(case_tac vs2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   647
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   648
apply (simp add: pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   649
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   650
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   651
apply (simp add: pflat_len_Stars_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   652
using pflat_len_def apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   653
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   654
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   655
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   656
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   657
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   658
apply (simp add: pflat_len_simps(7))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   659
apply (simp add: pflat_len_Stars_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   660
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   661
apply(auto simp add: pflat_len_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   662
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   663
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   664
apply(auto simp add: pflat_len_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   665
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   666
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   667
apply(auto simp add: pflat_len_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   668
apply(auto simp add: pflat_len_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   669
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   670
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   671
apply(auto simp add: pflat_len_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   672
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   673
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   674
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   675
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   676
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   677
lemma val_ord_SEQI:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   678
  assumes "v1 \<sqsubset>val p v1'" "flat (Seq v1 v2) = flat (Seq v1' v2')"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   679
  shows "(Seq v1 v2) \<sqsubset>val (0#p) (Seq v1' v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   680
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   681
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   682
apply(erule conjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   683
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   684
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   685
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   686
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   687
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   688
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   689
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   690
apply(simp only: Pos.simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   691
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   692
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   693
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   694
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   695
apply(auto simp add: pflat_len_simps)[2]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   696
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   697
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   698
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   699
lemma val_ord_SEQI2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   700
  assumes "v2 \<sqsubset>val p v2'" "flat v2 = flat v2'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   701
  shows "(Seq v v2) \<sqsubset>val (1#p) (Seq v v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   702
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   703
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   704
apply(erule conjE)+
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   705
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   706
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   707
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   708
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   709
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   710
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   711
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   712
apply(simp only: Pos.simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   713
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   714
apply(auto simp add: pflat_len_def intlen_append)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   715
apply(auto simp add: assms(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   716
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   717
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   718
lemma val_ord_SEQE_0:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   719
  assumes "(Seq v1 v2) \<sqsubset>val 0#p (Seq v1' v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   720
  shows "v1 \<sqsubset>val p v1'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   721
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   722
apply(simp add: val_ord_def val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   723
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   724
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   725
apply(simp add: val_ord_def pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   726
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   727
apply(drule_tac x="0#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   728
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   729
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   730
apply(drule_tac x="0#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   731
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   732
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   733
apply(drule_tac x="0#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   734
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   735
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   736
apply(simp add: val_ord_def pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   737
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   738
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   739
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   740
lemma val_ord_SEQE_1:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   741
  assumes "(Seq v1 v2) \<sqsubset>val (Suc 0)#p (Seq v1' v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   742
  shows "v2 \<sqsubset>val p v2'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   743
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   744
apply(simp add: val_ord_def pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   745
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   746
apply(drule_tac x="1#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   747
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   748
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   749
apply(drule_tac x="1#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   750
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   751
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   752
apply(drule_tac x="1#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   753
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   754
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   755
apply(drule_tac x="1#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   756
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   757
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   758
apply(simp add: intlen_append)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   759
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   760
apply(simp add: intlen_append)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   761
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   762
apply(simp add: intlen_append)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   763
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   764
apply(simp add: intlen_append)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   765
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   766
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   767
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   768
lemma val_ord_SEQE_2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   769
  assumes "(Seq v1 v2) \<sqsubset>val (Suc 0)#p (Seq v1' v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   770
  and "\<turnstile> v1 : r" "\<turnstile> v1' : r" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   771
  shows "v1 = v1'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   772
proof -
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   773
  have "\<forall>q \<in> Pos v1 \<union> Pos v1'. 0 # q \<sqsubset>lex 1#p \<longrightarrow> pflat_len v1 q = pflat_len v1' q"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   774
  using assms(1) 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   775
  apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   776
  apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   777
  apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   778
  apply(drule_tac x="0#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   779
  apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   780
  apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   781
  done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   782
  then have "Pos v1 = Pos v1'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   783
  apply(rule_tac Two_to_Three_orig)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   784
  apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   785
  apply(drule_tac x="pa" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   786
  apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   787
  apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   788
  done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   789
  then show "v1 = v1'" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   790
  apply(rule_tac Three_to_One)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   791
  apply(rule assms)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   792
  apply(rule assms)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   793
  apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   794
  done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   795
qed
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   796
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   797
lemma val_ord_SEQ:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   798
  assumes "(Seq v1 v2) :\<sqsubset>val (Seq v1' v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   799
  and "flat (Seq v1 v2) = flat (Seq v1' v2')"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   800
  and "\<turnstile> v1 : r" "\<turnstile> v1' : r" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   801
  shows "(v1 :\<sqsubset>val v1') \<or> (v1 = v1' \<and> (v2 :\<sqsubset>val v2'))"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   802
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   803
apply(subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   804
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   805
apply(simp only: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   806
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   807
apply(erule conjE)+
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   808
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   809
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   810
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   811
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   812
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   813
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   814
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   815
apply(rule_tac x="ps" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   816
apply(rule val_ord_SEQE_0)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   817
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   818
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   819
apply(rule disjI2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   820
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   821
thm val_ord_SEQE_1
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   822
apply(rule_tac val_ord_SEQE_2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   823
apply(auto simp add: val_ord_def)[3]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   824
apply(rule assms(3))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   825
apply(rule assms(4))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   826
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   827
apply(rule_tac x="ps" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   828
apply(rule_tac val_ord_SEQE_1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   829
apply(auto simp add: val_ord_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   830
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   831
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   832
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   833
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   834
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   835
lemma val_ord_ex_trans:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   836
  assumes "v1 :\<sqsubset>val v2" "v2 :\<sqsubset>val v3"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   837
  shows "v1 :\<sqsubset>val v3"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   838
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   839
unfolding val_ord_ex_def
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   840
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   841
apply(subgoal_tac "p = pa \<or> p \<sqsubset>lex pa \<or> pa \<sqsubset>lex p")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   842
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   843
apply(rule trichotomous)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   844
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   845
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   846
apply(rule_tac x="pa" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   847
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   848
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   849
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   850
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   851
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   852
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   853
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   854
using outside_lemma apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   855
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   856
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   857
using outside_lemma apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   858
apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   859
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   860
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   861
apply (metis (no_types, hide_lams) lex_trans outside_lemma)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   862
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   863
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   864
by (metis IntE Two_to_Three_aux UnCI lex_trans outside_lemma)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   865
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   866
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   867
definition fdpos :: "val \<Rightarrow> val \<Rightarrow> nat list \<Rightarrow> bool" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   868
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   869
  "fdpos v1 v2 p \<equiv>  ({q. q \<sqsubset>lex p} \<inter> DPos v1 v2 = {})"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   870
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   871
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   872
lemma pos_append:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   873
  assumes "p @ q \<in> Pos v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   874
  shows "q \<in> Pos (at v p)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   875
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   876
apply(induct arbitrary: p q rule: Pos.induct) 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   877
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   878
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   879
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   880
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   881
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   882
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   883
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   884
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   885
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   886
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   887
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   888
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   889
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   890
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   891
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   892
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   893
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   894
by (metis append_Cons at.simps(6))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   895
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   896
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   897
lemma Pos_pre:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   898
  assumes "p \<in> Pos v" "q \<sqsubseteq>pre p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   899
  shows "q \<in> Pos v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   900
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   901
apply(induct v arbitrary: p q rule: Pos.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   902
apply(simp_all add: prefix_list_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   903
apply (meson append_eq_Cons_conv append_is_Nil_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   904
apply (meson append_eq_Cons_conv append_is_Nil_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   905
apply (metis (no_types, lifting) Cons_eq_append_conv append_is_Nil_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   906
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   907
apply (meson append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   908
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   909
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   910
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   911
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   912
lemma lex_lists_order:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   913
  assumes "q' \<sqsubset>lex q" "\<not>(q' \<sqsubseteq>pre q)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   914
  shows "\<not>(q \<sqsubset>lex q')"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   915
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   916
apply(induct rule: lex_lists.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   917
apply(simp add: prefix_list_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   918
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   919
using trichotomous_aux2 by auto
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   920
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   921
lemma lex_appendL:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   922
  assumes "q \<sqsubset>lex p" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   923
  shows "q \<sqsubset>lex p @ q'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   924
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   925
apply(induct arbitrary: q' rule: lex_lists.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   926
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   927
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   928
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   929
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   930
inductive 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   931
  CPrf :: "val \<Rightarrow> rexp \<Rightarrow> bool" ("\<Turnstile> _ : _" [100, 100] 100)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   932
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   933
 "\<lbrakk>\<Turnstile> v1 : r1; \<Turnstile> v2 : r2\<rbrakk> \<Longrightarrow> \<Turnstile>  Seq v1 v2 : SEQ r1 r2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   934
| "\<Turnstile> v1 : r1 \<Longrightarrow> \<Turnstile> Left v1 : ALT r1 r2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   935
| "\<Turnstile> v2 : r2 \<Longrightarrow> \<Turnstile> Right v2 : ALT r1 r2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   936
| "\<Turnstile> Void : ONE"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   937
| "\<Turnstile> Char c : CHAR c"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   938
| "\<Turnstile> Stars [] : STAR r"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   939
| "\<lbrakk>\<Turnstile> v : r; flat v \<noteq> []; \<Turnstile> Stars vs : STAR r\<rbrakk> \<Longrightarrow> \<Turnstile> Stars (v # vs) : STAR r"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   940
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   941
lemma Prf_CPrf:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   942
  assumes "\<Turnstile> v : r"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   943
  shows "\<turnstile> v : r"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   944
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   945
apply(induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   946
apply(auto intro: Prf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   947
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   948
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   949
definition
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   950
  "CPT r s = {v. flat v = s \<and> \<Turnstile> v : r}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   951
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   952
definition
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   953
  "CPTpre r s = {v. \<exists>s'. flat v @ s' = s \<and> \<Turnstile> v : r}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   954
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   955
lemma CPT_CPTpre_subset:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   956
  shows "CPT r s \<subseteq> CPTpre r s"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   957
apply(auto simp add: CPT_def CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   958
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   959
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   960
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   961
lemma CPTpre_subsets:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   962
  "CPTpre ZERO s = {}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   963
  "CPTpre ONE s \<subseteq> {Void}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   964
  "CPTpre (CHAR c) s \<subseteq> {Char c}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   965
  "CPTpre (ALT r1 r2) s \<subseteq> Left ` CPTpre r1 s \<union> Right ` CPTpre r2 s"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   966
  "CPTpre (SEQ r1 r2) s \<subseteq> {Seq v1 v2 | v1 v2. v1 \<in> CPTpre r1 s \<and> v2 \<in> CPTpre r2 (drop (length (flat v1)) s)}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   967
  "CPTpre (STAR r) s \<subseteq> {Stars []} \<union>
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   968
    {Stars (v#vs) | v vs. v \<in> CPTpre r s \<and> flat v \<noteq> [] \<and> Stars vs \<in> CPTpre (STAR r) (drop (length (flat v)) s)}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   969
  "CPTpre (STAR r) [] = {Stars []}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   970
apply(auto simp add: CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   971
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   972
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   973
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   974
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   975
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   976
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   977
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   978
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   979
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   980
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   981
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   982
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   983
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   984
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   985
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   986
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   987
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   988
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   989
lemma CPTpre_simps:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   990
  shows "CPTpre ONE s = {Void}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   991
  and   "CPTpre (CHAR c) (d#s) = (if c = d then {Char c} else {})"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   992
  and   "CPTpre (ALT r1 r2) s = Left ` CPTpre r1 s \<union> Right ` CPTpre r2 s"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   993
  and   "CPTpre (SEQ r1 r2) s = 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   994
          {Seq v1 v2 | v1 v2. v1 \<in> CPTpre r1 s \<and> v2 \<in> CPTpre r2 (drop (length (flat v1)) s)}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   995
apply -
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   996
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   997
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   998
apply(auto simp add: CPTpre_def intro: "CPrf.intros")[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   999
apply(case_tac "c = d")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1000
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1001
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1002
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1003
apply(auto simp add: CPTpre_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1004
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1005
apply(auto simp add: CPTpre_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1006
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1007
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1008
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1009
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1010
apply(auto simp add: CPTpre_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1011
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1012
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1013
apply(auto simp add: CPTpre_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1014
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1015
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1016
lemma CPT_simps:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1017
  shows "CPT ONE s = (if s = [] then {Void} else {})"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1018
  and   "CPT (CHAR c) [d] = (if c = d then {Char c} else {})"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1019
  and   "CPT (ALT r1 r2) s = Left ` CPT r1 s \<union> Right ` CPT r2 s"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1020
  and   "CPT (SEQ r1 r2) s = 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1021
          {Seq v1 v2 | v1 v2 s1 s2. s1 @ s2 = s \<and> v1 \<in> CPT r1 s1 \<and> v2 \<in> CPT r2 s2}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1022
apply -
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1023
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1024
apply(auto simp add: CPT_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1025
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1026
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1027
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1028
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1029
apply(auto simp add: CPT_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1030
apply(auto simp add: CPT_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1031
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1032
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1033
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1034
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1035
apply(auto simp add: CPT_def image_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1036
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1037
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1038
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1039
apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1040
apply(auto simp add: CPT_def image_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1041
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1042
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1043
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1044
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1045
lemma CPTpre_SEQ:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1046
  assumes "v \<in> CPTpre (SEQ r1 r2) s"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1047
  shows "\<exists>s'. flat v = s' \<and> (s' \<sqsubseteq>pre s) \<and> s' \<in> L (SEQ r1 r2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1048
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1049
apply(simp add: CPTpre_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1050
apply(auto simp add: CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1051
apply (simp add: prefix_list_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1052
by (metis L.simps(4) L_flat_Prf1 Prf.intros(1) Prf_CPrf flat.simps(5))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1053
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1054
lemma Cond_prefix:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1055
  assumes "\<forall>s\<^sub>3. s1 @ s\<^sub>3 \<in> L r1 \<longrightarrow> s\<^sub>3 = [] \<or> (\<forall>s\<^sub>4. s1 @ s\<^sub>3 @ s\<^sub>4 \<sqsubseteq>pre s1 @ s2 \<longrightarrow> s\<^sub>4 \<notin> L r2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1056
  and "t1 \<in> L r1" "t2 \<in> L r2" "t1 @ t2 \<sqsubseteq>pre s1 @ s2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1057
  shows "t1 \<sqsubseteq>pre s1"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1058
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1059
apply(auto simp add: Sequ_def prefix_list_def append_eq_append_conv2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1060
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1061
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1062
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1063
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1064
lemma CPTpre_test:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1065
  assumes "s \<in> r \<rightarrow> v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1066
  shows "\<not>(\<exists>v' \<in> CPT r s. v :\<sqsubset>val v')"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1067
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1068
apply(induct r arbitrary: s v rule: rexp.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1069
apply(erule Posix.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1070
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1071
apply(erule Posix.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1072
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1073
apply(simp add: CPT_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1074
apply(simp add: val_ord_def val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1075
apply(erule Posix.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1076
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1077
apply(simp add: CPT_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1078
apply (simp add: val_ord_def val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1079
(* SEQ *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1080
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1081
apply(erule Posix.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1082
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1083
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1084
apply(subst (asm) CPT_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1085
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1086
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1087
thm val_ord_SEQ
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1088
apply(drule_tac ?r="r1" in val_ord_SEQ)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1089
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1090
apply (simp add: CPT_def Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1091
apply (simp add: Posix1a)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1092
apply (simp add: CPT_def Posix1a)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1093
using Prf_CPrf apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1094
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1095
apply(drule_tac x="s1" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1096
apply(drule_tac x="v1" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1097
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1098
apply(drule_tac x="v1a" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1099
apply(subgoal_tac "s1 = s1a")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1100
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1101
apply(auto simp add: append_eq_append_conv2)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1102
apply (metis (mono_tags, lifting) CPT_def L_flat_Prf1 Prf_CPrf append_Nil append_Nil2 mem_Collect_eq)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1103
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1104
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1105
oops
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1106
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1107
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1108
lemma test: 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1109
  assumes "finite A"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1110
  shows "finite {vs. Stars vs \<in> A}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1111
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1112
apply(induct A)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1113
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1114
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1115
apply(case_tac x)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1116
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1117
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1118
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1119
lemma CPTpre_STAR_finite:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1120
  assumes "\<And>s. finite (CPTpre r s)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1121
  shows "finite (CPTpre (STAR r) s)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1122
apply(induct s rule: length_induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1123
apply(case_tac xs)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1124
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1125
apply(simp add: CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1126
apply(rule finite_subset)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1127
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1128
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1129
apply(rule_tac B="(\<lambda>(v, vs). Stars (v#vs)) ` {(v, vs). v \<in> CPTpre r (a#list) \<and> flat v \<noteq> [] \<and> Stars vs \<in> CPTpre (STAR r) (drop (length (flat v)) (a#list))}" in finite_subset)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1130
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1131
apply(rule finite_imageI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1132
apply(simp add: Collect_case_prod_Sigma)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1133
apply(rule finite_SigmaI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1134
apply(rule assms)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1135
apply(case_tac "flat v = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1136
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1137
apply(drule_tac x="drop (length (flat v)) (a # list)" in spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1138
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1139
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1140
apply(rule test)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1141
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1142
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1143
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1144
lemma CPTpre_finite:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1145
  shows "finite (CPTpre r s)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1146
apply(induct r arbitrary: s)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1147
apply(simp add: CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1148
apply(rule finite_subset)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1149
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1150
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1151
apply(rule finite_subset)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1152
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1153
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1154
sorry
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1155
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1156
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1157
lemma CPT_finite:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1158
  shows "finite (CPT r s)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1159
apply(rule finite_subset)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1160
apply(rule CPT_CPTpre_subset)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1161
apply(rule CPTpre_finite)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1162
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1163
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1164
lemma Posix_CPT:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1165
  assumes "s \<in> r \<rightarrow> v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1166
  shows "v \<in> CPT r s"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1167
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1168
apply(induct rule: Posix.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1169
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1170
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1171
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1172
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1173
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1174
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1175
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1176
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1177
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1178
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1179
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1180
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1181
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1182
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1183
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1184
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1185
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1186
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1187
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1188
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1189
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1190
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1191
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1192
lemma Posix_val_ord:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1193
  assumes "s \<in> r \<rightarrow> v1" "v2 \<in> CPTpre r s" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1194
  shows "v1 :\<sqsubseteq>val v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1195
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1196
apply(induct arbitrary: v2 rule: Posix.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1197
apply(simp add: CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1198
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1199
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1200
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1201
apply(simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1202
apply(simp add: CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1203
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1204
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1205
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1206
apply(simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1207
(* ALT1 *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1208
prefer 3
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1209
(* SEQ case *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1210
apply(subst (asm) (3) CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1211
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1212
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1213
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1214
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1215
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1216
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1217
apply(simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1218
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1219
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1220
apply(simp add: val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1221
apply(simp (no_asm) add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1222
apply(rule_tac x="[]" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1223
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1224
apply(rule intlen_length)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1225
apply (metis Posix1(2) append_assoc append_eq_conv_conj drop_eq_Nil not_le)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1226
apply(subgoal_tac "length (flat v1a) \<le> length s1")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1227
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1228
apply (metis L_flat_Prf1 Prf_CPrf append_eq_append_conv_if append_take_drop_id drop_eq_Nil)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1229
apply(subst (asm) append_eq_append_conv_if)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1230
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1231
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1232
apply(drule_tac x="v1a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1233
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1234
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1235
using append_eq_conv_conj apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1236
apply(subst (asm) (2)val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1237
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1238
apply(subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1239
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1240
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1241
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1242
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1243
apply(rule_tac x="0#p" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1244
apply(rule val_ord_SEQI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1245
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1246
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1247
apply (metis Posix1(2) append_assoc append_take_drop_id)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1248
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1249
apply(drule_tac x="v2b" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1250
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1251
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1252
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1253
apply(subst (asm) val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1254
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1255
apply(subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1256
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1257
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1258
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1259
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1260
apply(rule_tac x="1#p" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1261
apply(rule val_ord_SEQI2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1262
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1263
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1264
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1265
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1266
(* ALT *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1267
apply(subst (asm) (2) CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1268
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1269
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1270
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1271
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1272
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1273
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1274
apply(drule_tac x="v1" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1275
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1276
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1277
apply(subst (asm) val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1278
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1279
apply(subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1280
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1281
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1282
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1283
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1284
apply(rule_tac x="0#p" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1285
apply(rule val_ord_ALTI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1286
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1287
using Posix1(2) apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1288
using val_ord_ex1_def apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1289
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1290
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1291
apply (simp add: Posix1(2) val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1292
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1293
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1294
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1295
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1296
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1297
apply(rule_tac x="[0]" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1298
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1299
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1300
apply(simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1301
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1302
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1303
apply (smt inlen_bigger)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1304
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1305
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1306
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1307
using Posix1(2) apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1308
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1309
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1310
apply(case_tac "q = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1311
using Posix1(2) apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1312
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1313
apply(rule val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1314
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1315
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1316
(* ALT RIGHT *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1317
apply(subst (asm) (2) CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1318
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1319
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1320
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1321
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1322
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1323
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1324
apply (simp add: L_flat_Prf1 Prf_CPrf)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1325
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1326
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1327
apply(rule val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1328
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1329
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1330
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1331
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1332
apply(drule_tac x="v2a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1333
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1334
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1335
apply(subst (asm) val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1336
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1337
apply(subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1338
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1339
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1340
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1341
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1342
apply(rule_tac x="1#p" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1343
apply(rule val_ord_ALTI2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1344
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1345
using Posix1(2) apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1346
apply (simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1347
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1348
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1349
apply(rule val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1350
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1351
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1352
(* STAR empty case *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1353
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1354
apply(subst (asm) CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1355
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1356
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1357
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1358
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1359
apply (simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1360
(* STAR non-empty case *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1361
apply(subst (asm) (3) CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1362
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1363
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1364
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1365
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1366
apply (simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1367
apply(rule val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1368
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1369
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1370
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1371
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1372
apply (simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1373
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1374
apply(rule val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1375
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1376
apply (metis Posix1(2) append_assoc append_eq_conv_conj drop_all flat.simps(7) flat_Stars length_append not_less)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1377
apply(drule_tac x="va" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1378
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1379
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1380
apply (smt L.simps(6) L_flat_Prf1 Prf_CPrf append_eq_append_conv2 flat_Stars self_append_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1381
apply (subst (asm) (2) val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1382
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1383
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1384
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1385
apply(drule_tac x="Stars vsa" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1386
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1387
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1388
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1389
apply (subst (asm) val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1390
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1391
apply (subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1392
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1393
apply (subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1394
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1395
apply (subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1396
apply(case_tac p)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1397
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1398
apply (metis Posix1(2) flat_Stars not_less_iff_gr_or_eq pflat_len_simps(7) same_append_eq val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1399
using Posix1(2) val_ord_STARI2 apply fastforce
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1400
apply(simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1401
apply (subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1402
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1403
apply (subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1404
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1405
apply (subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1406
by (metis Posix1(2) flat.simps(7) flat_Stars val_ord_STARI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1407
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1408
lemma Posix_val_ord_stronger:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1409
  assumes "s \<in> r \<rightarrow> v1" "v2 \<in> CPT r s" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1410
  shows "v1 :\<sqsubseteq>val v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1411
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1412
apply(rule_tac Posix_val_ord)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1413
apply(assumption)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1414
apply(simp add: CPTpre_def CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1415
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1416
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1417
definition Minval :: "rexp \<Rightarrow> string \<Rightarrow> val \<Rightarrow> bool"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1418
  where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1419
  "Minval r s v \<equiv> \<Turnstile> v : r \<and> flat v = s \<and> (\<forall>v' \<in> CPT r s. v :\<sqsubset>val v' \<or> v = v')"   
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1420
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1421
lemma 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1422
  assumes "s \<in> L(r)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1423
  shows "\<exists>v. Minval r s v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1424
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1425
apply(induct r arbitrary: s)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1426
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1427
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1428
apply(rule_tac x="Void" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1429
apply(simp add: Minval_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1430
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1431
apply (simp add: CPrf.intros(4))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1432
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1433
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1434
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1435
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1436
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1437
apply(rule_tac x="Char x" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1438
apply(simp add: Minval_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1439
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1440
apply (simp add: CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1441
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1442
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1443
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1444
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1445
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1446
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1447
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1448
apply(drule_tac x="s" in meta_spec) 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1449
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1450
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1451
apply(rule_tac x="Left x" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1452
apply(simp (no_asm) add: Minval_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1453
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1454
apply (simp add: CPrf.intros(2) Minval_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1455
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1456
apply(simp add: Minval_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1457
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1458
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1459
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1460
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1461
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1462
apply(simp add: val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1463
apply(simp only: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1464
oops
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1465
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1466
lemma
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1467
  "wf {(v1, v2). v1 \<in> CPT r s \<and> v2 \<in> CPT r s \<and> (v1 :\<sqsubset>val v2)}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1468
apply(rule wfI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1469
oops
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1470
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1471
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
  1472
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1473
  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
  1474
| 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
  1475
| 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
  1476
| 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
  1477
| 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
  1478
| 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
  1479
| 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
  1480
| 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
  1481
| 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
  1482
| K4: "(Stars vs1) \<preceq>(STAR r) (Stars vs2) \<Longrightarrow> (Stars (v # vs1)) \<preceq>(STAR r) (Stars (v # vs2))"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1483
| MY1: "Void \<preceq>ONE Void" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1484
| MY2: "(Char c) \<preceq>(CHAR c) (Char c)" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1485
| MY3: "(Stars []) \<preceq>(STAR r) (Stars [])" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1486
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1487
lemma ValOrd_refl: 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1488
  assumes "\<turnstile> v : r" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1489
  shows "v \<preceq>r v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1490
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1491
apply(induct r rule: Prf.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1492
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1493
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1494
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1495
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1496
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1497
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1498
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1499
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1500
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1501
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1502
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1503
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1504
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1505
lemma Posix_CPT2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1506
  assumes "v1 \<preceq>r v2" "flat v1 = flat v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1507
  shows "v2 :\<sqsubset>val v1 \<or> v1 = v2" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1508
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1509
apply(induct r arbitrary: v1 v2 rule: rexp.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1510
apply(erule ValOrd.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1511
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1512
apply(erule ValOrd.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1513
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1514
apply(erule ValOrd.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1515
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1516
apply(erule ValOrd.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1517
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1518
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1519
(* HERE *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1520
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1521
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1522
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1523
apply(drule_tac x="v2a" in  meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1524
apply(rotate_tac 5)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1525
apply(drule_tac x="v2'" in  meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1526
apply(rule_tac x="0#p" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1527
apply(rule val_ord_SEQI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1528
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1529
apply(drule_tac r="r1a" in  val_ord_SEQ)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1530
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1531
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1532
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1533
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1534
lemma Posix_CPT:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1535
  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
  1536
  shows "v1 \<preceq>r v2" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1537
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1538
apply(induct r arbitrary: v1 v2 s rule: rexp.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1539
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1540
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1541
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1542
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1543
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1544
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1545
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1546
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1547
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1548
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1549
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1550
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1551
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1552
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1553
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1554
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1555
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1556
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1557
(*SEQ case *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1558
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1559
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1560
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1561
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1562
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1563
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1564
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1565
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1566
thm val_ord_SEQ
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1567
apply(drule_tac r="r1a" in  val_ord_SEQ)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1568
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1569
using Prf_CPrf apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1570
using Prf_CPrf apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1571
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1572
apply(rule C2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1573
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1574
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1575
apply(rule C1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1576
apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1577
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1578
apply(simp add: append_eq_append_conv2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1579
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1580
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1581
apply(drule_tac x="v1a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1582
apply(rotate_tac 8)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1583
apply(drule_tac x="v1b" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1584
apply(rotate_tac 8)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1585
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1586
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1587
(* HERE *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1588
apply(subst (asm) (3) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1589
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1590
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1591
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1592
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1593
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1594
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1595
apply(simp add: val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1596
oops
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1597
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1598
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1599
lemma ValOrd_trans:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1600
  assumes "x \<preceq>r y" "y \<preceq>r z"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1601
  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
  1602
  shows "x \<preceq>r z"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1603
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1604
apply(induct x r y arbitrary: s z rule: ValOrd.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1605
apply(rotate_tac 2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1606
apply(erule ValOrd.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1607
apply(simp_all)[13]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1608
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1609
apply(drule_tac x="s" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1610
apply(drule_tac x="v1'a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1611
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1612
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1613
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1614
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1615
oops
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1616
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1617
lemma ValOrd_preorder:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1618
  "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
  1619
apply(simp add: preorder_on_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1620
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1621
apply(simp add: refl_on_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1622
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1623
apply(rule ValOrd_refl)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1624
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1625
apply(rule Prf_CPrf)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1626
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1627
apply(simp add: trans_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1628
apply(auto)
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1629
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1630
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
  1631
where 
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1632
  "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
  1633
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1634
(*
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1635
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1636
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1637
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
  1638
where
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1639
  "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
  1640
| "\<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
  1641
| "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
  1642
| "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
  1643
| "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
  1644
| "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
  1645
| "Void \<succ>EMPTY Void"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1646
| "(Char c) \<succ>(CHAR c) (Char c)"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1647
| "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
  1648
| "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
  1649
| "\<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
  1650
| "(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
  1651
| "(Stars []) \<succ>(STAR r) (Stars [])"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1652
*)
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1653
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1654
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1655
section {* Bit-Encodings *}
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1656
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1657
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1658
fun 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1659
  code :: "val \<Rightarrow> rexp \<Rightarrow> bool list"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1660
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1661
  "code Void ONE = []"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1662
| "code (Char c) (CHAR d) = []"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1663
| "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
  1664
| "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
  1665
| "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
  1666
| "code (Stars []) (STAR r) = [True]"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1667
| "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
  1668
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1669
fun 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1670
  Stars_add :: "val \<Rightarrow> val \<Rightarrow> val"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1671
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1672
  "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
  1673
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1674
function
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1675
  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
  1676
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1677
  "decode' ds ZERO = (Void, [])"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1678
| "decode' ds ONE = (Void, ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1679
| "decode' ds (CHAR d) = (Char d, ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1680
| "decode' [] (ALT r1 r2) = (Void, [])"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1681
| "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
  1682
| "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
  1683
| "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
  1684
                             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
  1685
| "decode' [] (STAR r) = (Void, [])"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1686
| "decode' (True # ds) (STAR r) = (Stars [], ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1687
| "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
  1688
                                    let (vs, ds'') = decode' ds' (STAR r) 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1689
                                    in (Stars_add v vs, ds''))"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1690
by pat_completeness auto
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1691
204
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1692
termination
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1693
apply(size_change)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1694
oops
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1695
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1696
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
  1697
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1698
lemma decode'_smaller:
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1699
  assumes "decode'_dom (ds, r)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1700
  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
  1701
using assms
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1702
apply(induct ds r)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1703
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
  1704
using dual_order.trans apply blast
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1705
by (meson dual_order.trans le_SucI)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1706
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1707
termination "decode'"  
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1708
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
  1709
apply(auto dest!: decode'_smaller)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1710
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
  1711
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1712
fun 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1713
  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
  1714
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1715
  "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
  1716
                  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
  1717
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1718
lemma decode'_code:
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1719
  assumes "\<turnstile> v : r"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1720
  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
  1721
using assms
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1722
by (induct v r arbitrary: ds) (auto)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1723
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1724
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1725
lemma decode_code:
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1726
  assumes "\<turnstile> v : r"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1727
  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
  1728
using assms decode'_code[of _ _ "[]"]
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1729
by auto
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1730
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1731
datatype arexp =
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1732
  AZERO
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1733
| AONE "bool list"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1734
| ACHAR "bool list" char
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1735
| ASEQ "bool list" arexp arexp
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1736
| AALT "bool list" arexp arexp
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1737
| ASTAR "bool list" arexp
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1738
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1739
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
  1740
  "fuse bs AZERO = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1741
| "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
  1742
| "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
  1743
| "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
  1744
| "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
  1745
| "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
  1746
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1747
fun internalise :: "rexp \<Rightarrow> arexp" where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1748
  "internalise ZERO = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1749
| "internalise ONE = AONE []"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1750
| "internalise (CHAR c) = ACHAR [] c"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1751
| "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
  1752
                                     (fuse [True]  (internalise r2))"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1753
| "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
  1754
| "internalise (STAR r) = ASTAR [] (internalise r)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1755
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1756
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
  1757
  "retrieve (AONE bs) Void = bs"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1758
| "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
  1759
| "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
  1760
| "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
  1761
| "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
  1762
| "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
  1763
| "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
  1764
     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
  1765
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1766
fun
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1767
 anullable :: "arexp \<Rightarrow> bool"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1768
where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1769
  "anullable (AZERO) = False"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1770
| "anullable (AONE bs) = True"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1771
| "anullable (ACHAR bs c) = False"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1772
| "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
  1773
| "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
  1774
| "anullable (ASTAR bs r) = True"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1775
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1776
fun 
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1777
  amkeps :: "arexp \<Rightarrow> bool list"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1778
where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1779
  "amkeps(AONE bs) = bs"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1780
| "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
  1781
| "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
  1782
| "amkeps(ASTAR bs r) = bs @ [True]"
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1783
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1784
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1785
fun
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1786
 ader :: "char \<Rightarrow> arexp \<Rightarrow> arexp"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1787
where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1788
  "ader c (AZERO) = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1789
| "ader c (AONE bs) = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1790
| "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
  1791
| "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
  1792
| "ader c (ASEQ bs r1 r2) = 
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1793
     (if anullable r1
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1794
      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
  1795
      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
  1796
| "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
  1797
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1798
lemma
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1799
  assumes "\<turnstile> v : der c r"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1800
  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
  1801
using assms
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1802
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
  1803
apply(simp_all)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1804
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1805
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1806
apply(case_tac "c = d")
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1807
apply(simp)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1808
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1809
apply(simp)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1810
apply(simp)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1811
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1812
apply(auto split: prod.splits)[1]
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1813
oops
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1814
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1815
end