thys/Sulzmann.thy
author Christian Urban <urbanc@in.tum.de>
Sat, 24 Jun 2017 18:50:26 +0100
changeset 246 23657fad2017
parent 245 b16702bb6242
child 247 f35753951058
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
246
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   167
lemma pflat_len_Stars_simps2:
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   168
  shows "pflat_len (Stars (v#vs)) (Suc n # p) = pflat_len (Stars vs) (n#p)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   169
  and   "pflat_len (Stars (v#vs)) (0 # p) = pflat_len v p"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   170
using assms 
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   171
apply(simp_all add: pflat_len_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   172
done
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   173
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   174
lemma Two_to_Three_aux:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   175
  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
   176
  shows "p \<in> Pos v1 \<inter> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   177
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   178
apply(simp add: pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   179
apply(auto split: if_splits)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   180
apply (smt inlen_bigger)+
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   181
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   182
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   183
lemma Two_to_Three:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   184
  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
   185
  shows "Pos v1 = Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   186
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   187
by (metis Un_iff option.distinct(1) pflat_def subsetI subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   188
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   189
lemma Two_to_Three_orig:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   190
  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
   191
  shows "Pos v1 = Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   192
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   193
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
   194
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   195
lemma set_eq1:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   196
  assumes "insert [] A = insert [] B" "[] \<notin> A"  "[] \<notin> B"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   197
  shows "A = B"
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
by (simp add: insert_ident)
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
lemma set_eq2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   202
  assumes "A \<union> B = A \<union> C"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   203
  and "A \<inter> B = {}" "A \<inter> C = {}"  
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   204
  shows "B = C"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   205
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   206
using Un_Int_distrib sup_bot.left_neutral sup_commute by blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   207
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   208
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   209
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   210
lemma Three_to_One:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   211
  assumes "\<turnstile> v1 : r" "\<turnstile> v2 : r" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   212
  and "Pos v1 = Pos v2" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   213
  shows "v1 = v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   214
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   215
apply(induct v1 arbitrary: r v2 rule: Pos.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   216
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   217
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   218
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   219
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   220
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   221
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   222
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   223
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   224
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   225
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   226
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   227
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   228
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   229
apply(simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   230
apply(drule_tac x="r1a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   231
apply(drule_tac x="v1a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   232
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   233
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   234
thm subset_antisym
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   235
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   236
apply(auto)[3]
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(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   241
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   242
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   243
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   244
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   245
apply(simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   246
using Pos_empty apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   247
apply(simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   248
apply(drule_tac x="r2a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   249
apply(drule_tac x="v2b" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   250
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   251
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   252
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   253
apply(auto)[3]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   254
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   255
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   256
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   257
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   258
apply(simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   259
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   260
apply(drule_tac x="r1a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   261
apply(drule_tac x="r2a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   262
apply(drule_tac x="v1b" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   263
apply(drule_tac x="v2c" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   264
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   265
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   266
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   267
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   268
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
   269
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   270
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   271
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
   272
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   273
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   274
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   275
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   276
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
   277
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   278
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   279
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
   280
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   281
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   282
apply(simp (no_asm_use))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   283
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   284
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   285
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   286
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   287
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
   288
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   289
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   290
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
   291
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   292
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   293
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   294
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   295
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
   296
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   297
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   298
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
   299
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   300
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   301
apply(simp (no_asm_use))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   302
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   303
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   304
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   305
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   306
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   307
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   308
using Pos_empty apply fastforce
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   309
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   310
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   311
apply(erule Prf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   312
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   313
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   314
using Pos_empty apply fastforce
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   315
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   316
apply(simp add: insert_ident)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   317
apply(drule_tac x="rb" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   318
apply(drule_tac x="STAR rb" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   319
apply(drule_tac x="vb" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   320
apply(drule_tac x="Stars vsb" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   321
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   322
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   323
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   324
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   325
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
   326
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   327
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   328
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
   329
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   330
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   331
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   332
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   333
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
   334
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   335
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   336
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
   337
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   338
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   339
apply(simp (no_asm_use))
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(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   342
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   343
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   344
apply(case_tac vsa)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   345
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   346
apply (simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   347
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   348
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   349
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   350
apply (simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   351
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   352
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   353
apply(subgoal_tac 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   354
  "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
   355
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   356
apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   357
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
   358
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   359
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   360
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   361
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   362
apply(subgoal_tac 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   363
  "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
   364
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   365
apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   366
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
   367
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   368
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   369
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   370
apply(rule subsetI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   371
apply(case_tac vsb)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   372
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   373
apply (simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   374
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   375
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   376
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   377
apply (simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   378
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   379
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   380
apply(subgoal_tac 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   381
  "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
   382
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   383
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   384
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
   385
apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   386
using list.inject apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   387
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   388
apply(subgoal_tac 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   389
  "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
   390
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   391
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   392
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
   393
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   394
apply (metis (no_types, lifting) Un_iff)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   395
apply(simp (no_asm_use))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   396
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   397
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   398
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   399
definition prefix_list:: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<sqsubseteq>pre _")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   400
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   401
  "ps1 \<sqsubseteq>pre ps2 \<equiv> (\<exists>ps'. ps1 @ps' = ps2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   402
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   403
definition sprefix_list:: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<sqsubset>spre _")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   404
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   405
  "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
   406
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   407
inductive lex_lists :: "nat list \<Rightarrow> nat list \<Rightarrow> bool" ("_ \<sqsubset>lex _")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   408
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   409
  "[] \<sqsubset>lex p#ps"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   410
| "ps1 \<sqsubset>lex ps2 \<Longrightarrow> (p#ps1) \<sqsubset>lex (p#ps2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   411
| "p1 < p2 \<Longrightarrow> (p1#ps1) \<sqsubset>lex (p2#ps2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   412
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   413
lemma lex_irrfl:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   414
  fixes ps1 ps2 :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   415
  assumes "ps1 \<sqsubset>lex ps2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   416
  shows "ps1 \<noteq> ps2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   417
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   418
apply(induct rule: lex_lists.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   419
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   420
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   421
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   422
lemma lex_append:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   423
  assumes "ps2 \<noteq> []"  
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   424
  shows "ps \<sqsubset>lex ps @ ps2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   425
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   426
apply(induct ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   427
apply(auto intro: lex_lists.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   428
apply(case_tac ps2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   429
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   430
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   431
apply(auto intro: lex_lists.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   432
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   433
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   434
lemma lexordp_simps [simp]:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   435
  fixes xs ys :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   436
  shows "[] \<sqsubset>lex ys = (ys \<noteq> [])"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   437
  and   "xs \<sqsubset>lex [] = False"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   438
  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
   439
apply -
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   440
apply (metis lex_append lex_lists.simps list.simps(3))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   441
using lex_lists.cases apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   442
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
   443
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   444
lemma lex_append_cancel [simp]:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   445
  fixes ps ps1 ps2 :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   446
  shows "ps @ ps1 \<sqsubset>lex ps @ ps2 \<longleftrightarrow> ps1 \<sqsubset>lex ps2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   447
apply(induct ps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   448
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   449
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   450
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   451
lemma lex_trans:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   452
  fixes ps1 ps2 ps3 :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   453
  assumes "ps1 \<sqsubset>lex ps2" "ps2 \<sqsubset>lex ps3"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   454
  shows "ps1 \<sqsubset>lex ps3"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   455
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   456
apply(induct arbitrary: ps3 rule: lex_lists.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   457
apply(erule lex_lists.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   458
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   459
apply(rotate_tac 2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   460
apply(erule lex_lists.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   461
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   462
apply(erule lex_lists.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   463
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   464
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   465
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   466
lemma trichotomous_aux:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   467
  fixes p q :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   468
  assumes "p \<sqsubset>lex q" "p \<noteq> q"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   469
  shows "\<not>(q \<sqsubset>lex p)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   470
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   471
apply(induct rule: lex_lists.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   472
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   473
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   474
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   475
lemma trichotomous_aux2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   476
  fixes p q :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   477
  assumes "p \<sqsubset>lex q" "q \<sqsubset>lex p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   478
  shows "False"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   479
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   480
apply(induct rule: lex_lists.induct)
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
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   483
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   484
lemma trichotomous:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   485
  fixes p q :: "nat list"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   486
  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
   487
apply(induct p arbitrary: q)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   488
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   489
apply(case_tac q)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   490
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   491
done
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
definition dpos :: "val \<Rightarrow> val \<Rightarrow> nat list \<Rightarrow> bool" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   494
  where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   495
  "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
   496
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   497
definition
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   498
  "DPos v1 v2 \<equiv> {p. dpos v1 v2 p}"
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 outside_lemma:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   501
  assumes "p \<notin> Pos v1 \<union> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   502
  shows "pflat_len v1 p = pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   503
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   504
apply(auto simp add: pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   505
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   506
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   507
lemma dpos_lemma_aux:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   508
  assumes "p \<in> Pos v1 \<union> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   509
  and "pflat_len v1 p = pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   510
  shows "p \<in> Pos v1 \<inter> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   511
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   512
apply(auto simp add: pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   513
apply (smt inlen_bigger)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   514
apply (smt inlen_bigger)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   515
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   516
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   517
lemma dpos_lemma:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   518
  assumes "p \<in> Pos v1 \<union> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   519
  and "pflat_len v1 p = pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   520
  shows "\<not>dpos v1 v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   521
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   522
apply(auto simp add: dpos_def dpos_lemma_aux)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   523
using dpos_lemma_aux apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   524
using dpos_lemma_aux apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   525
done
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_lemma2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   528
  assumes "p \<in> Pos v1 \<union> Pos v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   529
  and "dpos v1 v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   530
  shows "pflat_len v1 p \<noteq> pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   531
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   532
using dpos_lemma by blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   533
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   534
lemma DPos_lemma:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   535
  assumes "p \<in> DPos v1 v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   536
  shows "pflat_len v1 p \<noteq> pflat_len v2 p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   537
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   538
unfolding DPos_def 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   539
apply(auto simp add: pflat_len_def dpos_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   540
apply (smt inlen_bigger)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   541
by (smt inlen_bigger)
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
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   544
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
   545
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   546
  "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
   547
                   (\<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
   548
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   549
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   550
definition val_ord_ex:: "val \<Rightarrow> val \<Rightarrow> bool" ("_ :\<sqsubset>val _")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   551
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   552
  "v1 :\<sqsubset>val v2 \<equiv> (\<exists>p. v1 \<sqsubset>val p v2)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   553
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   554
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
   555
where
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   556
  "v1 :\<sqsubseteq>val v2 \<equiv> v1 :\<sqsubset>val v2 \<or> v1 = v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   557
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   558
lemma val_ord_shorterI:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   559
  assumes "length (flat v') < length (flat v)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   560
  shows "v :\<sqsubset>val v'" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   561
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   562
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   563
apply(rule_tac x="[]" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   564
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   565
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   566
apply (simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   567
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   568
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   569
apply (simp add: intlen_length)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   570
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   571
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   572
lemma val_ord_ALTI:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   573
  assumes "v \<sqsubset>val p v'" "flat v = flat v'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   574
  shows "(Left v) \<sqsubset>val (0#p) (Left v')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   575
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   576
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   577
apply(erule conjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   578
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   579
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   580
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   581
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   582
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   583
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   584
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   585
apply(simp only: Pos.simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   586
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   587
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   588
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   589
apply(auto simp add: pflat_len_simps)[2]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   590
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   591
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   592
lemma val_ord_ALTI2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   593
  assumes "v \<sqsubset>val p v'" "flat v = flat v'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   594
  shows "(Right v) \<sqsubset>val (1#p) (Right v')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   595
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   596
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   597
apply(erule conjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   598
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   599
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   600
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   601
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   602
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   603
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   604
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   605
apply(simp only: Pos.simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   606
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   607
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   608
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   609
apply(auto simp add: pflat_len_simps)[2]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   610
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   611
246
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   612
lemma val_ord_ALTE:
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   613
  assumes "(Left v1) \<sqsubset>val (p # ps) (Left v2)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   614
  shows "p = 0 \<and> v1 \<sqsubset>val ps v2"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   615
using assms(1)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   616
apply(simp add: val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   617
apply(auto simp add: pflat_len_simps)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   618
apply (metis (no_types, hide_lams) assms lex_lists.intros(2) outside_lemma pflat_len_simps(3) val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   619
by (metis (no_types, hide_lams) assms lex_lists.intros(2) outside_lemma pflat_len_simps(3) val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   620
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   621
lemma val_ord_ALTE2:
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   622
  assumes "(Right v1) \<sqsubset>val (p # ps) (Right v2)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   623
  shows "p = 1 \<and> v1 \<sqsubset>val ps v2"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   624
using assms(1)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   625
apply(simp add: val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   626
apply(auto simp add: pflat_len_simps)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   627
apply (metis (no_types, hide_lams) assms lex_lists.intros(2) outside_lemma pflat_len_simps(5) val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   628
by (metis (no_types, hide_lams) assms lex_lists.intros(2) outside_lemma pflat_len_simps(5) val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   629
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   630
lemma val_ord_STARI:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   631
  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
   632
  shows "(Stars (v1#vs1)) \<sqsubset>val (0#p) (Stars (v2#vs2))" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   633
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   634
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   635
apply(erule conjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   636
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   637
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   638
apply(simp)
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(subst pflat_len_Stars_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   641
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   642
apply(subst pflat_len_Stars_simps)
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(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   646
apply(rule impI)
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(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   649
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   650
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   651
apply(auto simp add: pflat_len_Stars_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   652
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   653
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   654
lemma val_ord_STARI2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   655
  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
   656
  shows "(Stars (v#vs1)) \<sqsubset>val (Suc n#p) (Stars (v#vs2))" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   657
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   658
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   659
apply(erule conjE)+
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   660
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   661
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   662
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   663
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   664
apply(case_tac vs1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   665
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   666
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   667
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   668
apply(case_tac vs2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   669
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   670
apply (simp add: pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   671
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   672
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   673
apply (simp add: pflat_len_Stars_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   674
using pflat_len_def apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   675
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   676
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   677
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   678
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   679
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   680
apply (simp add: pflat_len_simps(7))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   681
apply (simp add: pflat_len_Stars_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   682
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   683
apply(auto simp add: pflat_len_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   684
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   685
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   686
apply(auto simp add: pflat_len_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   687
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   688
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   689
apply(auto simp add: pflat_len_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   690
apply(auto simp add: pflat_len_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   691
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   692
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   693
apply(auto simp add: pflat_len_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   694
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   695
apply force
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_SEQI:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   700
  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
   701
  shows "(Seq v1 v2) \<sqsubset>val (0#p) (Seq v1' 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)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   714
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   715
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   716
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   717
apply(auto simp add: pflat_len_simps)[2]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   718
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   719
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   720
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   721
lemma val_ord_SEQI2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   722
  assumes "v2 \<sqsubset>val p v2'" "flat v2 = flat v2'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   723
  shows "(Seq v v2) \<sqsubset>val (1#p) (Seq v v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   724
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   725
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   726
apply(erule conjE)+
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   727
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   728
apply(rule conjI)
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(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   731
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   732
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   733
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   734
apply(simp only: Pos.simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   735
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   736
apply(auto simp add: pflat_len_def intlen_append)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   737
apply(auto simp add: assms(2))
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_0:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   741
  assumes "(Seq v1 v2) \<sqsubset>val 0#p (Seq v1' v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   742
  shows "v1 \<sqsubset>val p v1'"
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 val_ord_ex_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(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   747
apply(simp add: val_ord_def pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   748
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   749
apply(drule_tac x="0#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="0#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(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   755
apply(drule_tac x="0#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(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   758
apply(simp add: val_ord_def pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   759
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   760
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   761
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   762
lemma val_ord_SEQE_1:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   763
  assumes "(Seq v1 v2) \<sqsubset>val (Suc 0)#p (Seq v1' v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   764
  shows "v2 \<sqsubset>val p v2'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   765
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   766
apply(simp add: val_ord_def pflat_len_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   767
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   768
apply(drule_tac x="1#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   769
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   770
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   771
apply(drule_tac x="1#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   772
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   773
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   774
apply(drule_tac x="1#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   775
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   776
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   777
apply(drule_tac x="1#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   778
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   779
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   780
apply(simp add: intlen_append)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   781
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   782
apply(simp add: intlen_append)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   783
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   784
apply(simp add: intlen_append)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   785
apply force
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   786
apply(simp add: intlen_append)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   787
apply force
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
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   790
lemma val_ord_SEQE_2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   791
  assumes "(Seq v1 v2) \<sqsubset>val (Suc 0)#p (Seq v1' v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   792
  and "\<turnstile> v1 : r" "\<turnstile> v1' : r" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   793
  shows "v1 = v1'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   794
proof -
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   795
  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
   796
  using assms(1) 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   797
  apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   798
  apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   799
  apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   800
  apply(drule_tac x="0#q" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   801
  apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   802
  apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   803
  done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   804
  then have "Pos v1 = Pos v1'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   805
  apply(rule_tac Two_to_Three_orig)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   806
  apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   807
  apply(drule_tac x="pa" in bspec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   808
  apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   809
  apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   810
  done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   811
  then show "v1 = v1'" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   812
  apply(rule_tac Three_to_One)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   813
  apply(rule assms)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   814
  apply(rule assms)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   815
  apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   816
  done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   817
qed
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   818
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   819
lemma val_ord_SEQ:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   820
  assumes "(Seq v1 v2) :\<sqsubset>val (Seq v1' v2')" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   821
  and "flat (Seq v1 v2) = flat (Seq v1' v2')"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   822
  and "\<turnstile> v1 : r" "\<turnstile> v1' : r" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   823
  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
   824
using assms(1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   825
apply(subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   826
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   827
apply(simp only: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   828
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   829
apply(erule conjE)+
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   830
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   831
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   832
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   833
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   834
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   835
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   836
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   837
apply(rule_tac x="ps" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   838
apply(rule val_ord_SEQE_0)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   839
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   840
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   841
apply(rule disjI2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   842
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   843
thm val_ord_SEQE_1
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   844
apply(rule_tac val_ord_SEQE_2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   845
apply(auto simp add: val_ord_def)[3]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   846
apply(rule assms(3))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   847
apply(rule assms(4))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   848
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   849
apply(rule_tac x="ps" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   850
apply(rule_tac val_ord_SEQE_1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   851
apply(auto simp add: val_ord_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   852
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   853
using assms(2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   854
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   855
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   856
246
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
   857
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   858
lemma val_ord_ex_trans:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   859
  assumes "v1 :\<sqsubset>val v2" "v2 :\<sqsubset>val v3"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   860
  shows "v1 :\<sqsubset>val v3"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   861
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   862
unfolding val_ord_ex_def
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   863
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   864
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
   865
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   866
apply(rule trichotomous)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   867
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   868
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   869
apply(rule_tac x="pa" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   870
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   871
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   872
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   873
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   874
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   875
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   876
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   877
using outside_lemma apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   878
apply(simp add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   879
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   880
using outside_lemma apply force
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: val_ord_def)
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 (metis (no_types, hide_lams) lex_trans outside_lemma)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   885
apply(simp add: val_ord_def)
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
by (metis IntE Two_to_Three_aux UnCI lex_trans outside_lemma)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   888
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   889
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   890
definition fdpos :: "val \<Rightarrow> val \<Rightarrow> nat list \<Rightarrow> bool" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   891
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   892
  "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
   893
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   894
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   895
lemma pos_append:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   896
  assumes "p @ q \<in> Pos v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   897
  shows "q \<in> Pos (at v p)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   898
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   899
apply(induct arbitrary: p q rule: Pos.induct) 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   900
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   901
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   902
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   903
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   904
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   905
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   906
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   907
apply(auto)[1]
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)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   910
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   911
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   912
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   913
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   914
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   915
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   916
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   917
by (metis append_Cons at.simps(6))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   918
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   919
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   920
lemma Pos_pre:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   921
  assumes "p \<in> Pos v" "q \<sqsubseteq>pre p"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   922
  shows "q \<in> Pos v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   923
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   924
apply(induct v arbitrary: p q rule: Pos.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   925
apply(simp_all add: prefix_list_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   926
apply (meson append_eq_Cons_conv append_is_Nil_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   927
apply (meson append_eq_Cons_conv append_is_Nil_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   928
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
   929
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   930
apply (meson append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   931
apply(simp add: append_eq_Cons_conv)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   932
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   933
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   934
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   935
lemma lex_lists_order:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   936
  assumes "q' \<sqsubset>lex q" "\<not>(q' \<sqsubseteq>pre q)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   937
  shows "\<not>(q \<sqsubset>lex q')"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   938
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   939
apply(induct rule: lex_lists.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   940
apply(simp add: prefix_list_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   941
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   942
using trichotomous_aux2 by auto
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   943
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   944
lemma lex_appendL:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   945
  assumes "q \<sqsubset>lex p" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   946
  shows "q \<sqsubset>lex p @ q'"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   947
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   948
apply(induct arbitrary: q' rule: lex_lists.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   949
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   950
done
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
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   953
inductive 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   954
  CPrf :: "val \<Rightarrow> rexp \<Rightarrow> bool" ("\<Turnstile> _ : _" [100, 100] 100)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   955
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   956
 "\<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
   957
| "\<Turnstile> v1 : r1 \<Longrightarrow> \<Turnstile> Left v1 : ALT r1 r2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   958
| "\<Turnstile> v2 : r2 \<Longrightarrow> \<Turnstile> Right v2 : ALT r1 r2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   959
| "\<Turnstile> Void : ONE"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   960
| "\<Turnstile> Char c : CHAR c"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   961
| "\<Turnstile> Stars [] : STAR r"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   962
| "\<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
   963
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   964
lemma Prf_CPrf:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   965
  assumes "\<Turnstile> v : r"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   966
  shows "\<turnstile> v : r"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   967
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   968
apply(induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   969
apply(auto intro: Prf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   970
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   971
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   972
definition
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   973
  "CPT r s = {v. flat v = s \<and> \<Turnstile> v : r}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   974
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   975
definition
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   976
  "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
   977
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   978
lemma CPT_CPTpre_subset:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   979
  shows "CPT r s \<subseteq> CPTpre r s"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   980
apply(auto simp add: CPT_def CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   981
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   982
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   983
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   984
lemma CPTpre_subsets:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   985
  "CPTpre ZERO s = {}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   986
  "CPTpre ONE s \<subseteq> {Void}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   987
  "CPTpre (CHAR c) s \<subseteq> {Char c}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   988
  "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
   989
  "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
   990
  "CPTpre (STAR r) s \<subseteq> {Stars []} \<union>
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   991
    {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
   992
  "CPTpre (STAR r) [] = {Stars []}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   993
apply(auto simp add: CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   994
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   995
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   996
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   997
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   998
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
   999
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1000
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1001
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1002
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1003
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1004
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1005
apply(simp_all)
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 CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1009
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1010
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1011
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1012
lemma CPTpre_simps:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1013
  shows "CPTpre ONE s = {Void}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1014
  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
  1015
  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
  1016
  and   "CPTpre (SEQ r1 r2) s = 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1017
          {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
  1018
apply -
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1019
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1020
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1021
apply(auto simp add: CPTpre_def intro: "CPrf.intros")[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1022
apply(case_tac "c = d")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1023
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1024
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1025
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1026
apply(auto simp add: CPTpre_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1027
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1028
apply(auto simp add: CPTpre_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1029
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1030
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1031
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1032
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1033
apply(auto simp add: CPTpre_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1034
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1035
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1036
apply(auto simp add: CPTpre_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1037
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1038
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1039
lemma CPT_simps:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1040
  shows "CPT ONE s = (if s = [] then {Void} else {})"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1041
  and   "CPT (CHAR c) [d] = (if c = d then {Char c} else {})"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1042
  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
  1043
  and   "CPT (SEQ r1 r2) s = 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1044
          {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
  1045
apply -
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1046
apply(rule subset_antisym)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1047
apply(auto simp add: CPT_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1048
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1049
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1050
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1051
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1052
apply(auto simp add: CPT_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1053
apply(auto simp add: CPT_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1054
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1055
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1056
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1057
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1058
apply(auto simp add: CPT_def image_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1059
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1060
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1061
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1062
apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1063
apply(auto simp add: CPT_def image_def intro: CPrf.intros)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1064
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1065
apply(simp_all)[7]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1066
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1067
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1068
lemma CPTpre_SEQ:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1069
  assumes "v \<in> CPTpre (SEQ r1 r2) s"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1070
  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
  1071
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1072
apply(simp add: CPTpre_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1073
apply(auto simp add: CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1074
apply (simp add: prefix_list_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1075
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
  1076
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1077
lemma Cond_prefix:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1078
  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
  1079
  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
  1080
  shows "t1 \<sqsubseteq>pre s1"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1081
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1082
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
  1083
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1084
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1085
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1086
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1087
lemma test: 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1088
  assumes "finite A"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1089
  shows "finite {vs. Stars vs \<in> A}"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1090
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1091
apply(induct A)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1092
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1093
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1094
apply(case_tac x)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1095
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1096
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1097
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1098
lemma CPTpre_STAR_finite:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1099
  assumes "\<And>s. finite (CPTpre r s)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1100
  shows "finite (CPTpre (STAR r) s)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1101
apply(induct s rule: length_induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1102
apply(case_tac xs)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1103
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1104
apply(simp add: CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1105
apply(rule finite_subset)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1106
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1107
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1108
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
  1109
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1110
apply(rule finite_imageI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1111
apply(simp add: Collect_case_prod_Sigma)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1112
apply(rule finite_SigmaI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1113
apply(rule assms)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1114
apply(case_tac "flat v = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1115
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1116
apply(drule_tac x="drop (length (flat v)) (a # list)" in spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1117
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1118
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1119
apply(rule test)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1120
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1121
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1122
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1123
lemma CPTpre_finite:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1124
  shows "finite (CPTpre r s)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1125
apply(induct r arbitrary: s)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1126
apply(simp add: CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1127
apply(rule finite_subset)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1128
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1129
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1130
apply(rule finite_subset)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1131
apply(rule CPTpre_subsets)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1132
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1133
sorry
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1134
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1135
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1136
lemma CPT_finite:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1137
  shows "finite (CPT r s)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1138
apply(rule finite_subset)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1139
apply(rule CPT_CPTpre_subset)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1140
apply(rule CPTpre_finite)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1141
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1142
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1143
lemma Posix_CPT:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1144
  assumes "s \<in> r \<rightarrow> v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1145
  shows "v \<in> CPT r s"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1146
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1147
apply(induct rule: Posix.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1148
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1149
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1150
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1151
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1152
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1153
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1154
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1155
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1156
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1157
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1158
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1159
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1160
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1161
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1162
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1163
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1164
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1165
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1166
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1167
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1168
apply(rule CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1169
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1170
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1171
lemma Posix_val_ord:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1172
  assumes "s \<in> r \<rightarrow> v1" "v2 \<in> CPTpre r s" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1173
  shows "v1 :\<sqsubseteq>val v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1174
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1175
apply(induct arbitrary: v2 rule: Posix.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1176
apply(simp add: CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1177
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1178
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1179
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1180
apply(simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1181
apply(simp add: CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1182
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1183
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1184
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1185
apply(simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1186
(* ALT1 *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1187
prefer 3
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1188
(* SEQ case *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1189
apply(subst (asm) (3) CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1190
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1191
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1192
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1193
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1194
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1195
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1196
apply(simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1197
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1198
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1199
apply(simp add: val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1200
apply(simp (no_asm) add: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1201
apply(rule_tac x="[]" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1202
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1203
apply(rule intlen_length)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1204
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
  1205
apply(subgoal_tac "length (flat v1a) \<le> length s1")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1206
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1207
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
  1208
apply(subst (asm) append_eq_append_conv_if)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1209
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1210
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1211
apply(drule_tac x="v1a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1212
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1213
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1214
using append_eq_conv_conj apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1215
apply(subst (asm) (2)val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1216
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1217
apply(subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1218
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1219
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1220
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1221
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1222
apply(rule_tac x="0#p" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1223
apply(rule val_ord_SEQI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1224
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1225
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1226
apply (metis Posix1(2) append_assoc append_take_drop_id)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1227
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1228
apply(drule_tac x="v2b" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1229
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1230
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1231
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1232
apply(subst (asm) val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1233
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1234
apply(subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1235
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1236
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1237
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1238
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1239
apply(rule_tac x="1#p" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1240
apply(rule val_ord_SEQI2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1241
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1242
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1243
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1244
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1245
(* ALT *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1246
apply(subst (asm) (2) CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1247
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1248
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1249
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1250
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1251
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1252
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1253
apply(drule_tac x="v1" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1254
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1255
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1256
apply(subst (asm) val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1257
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1258
apply(subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1259
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1260
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1261
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1262
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1263
apply(rule_tac x="0#p" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1264
apply(rule val_ord_ALTI)
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
using Posix1(2) apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1267
using val_ord_ex1_def apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1268
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1269
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1270
apply (simp add: Posix1(2) val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1271
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1272
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1273
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1274
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1275
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1276
apply(rule_tac x="[0]" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1277
apply(subst val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1278
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1279
apply(simp add: Pos_empty)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1280
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1281
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1282
apply (smt inlen_bigger)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1283
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1284
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1285
apply(simp add: pflat_len_simps)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1286
using Posix1(2) apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1287
apply(rule ballI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1288
apply(rule impI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1289
apply(case_tac "q = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1290
using Posix1(2) apply auto[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1291
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1292
apply(rule val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1293
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1294
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1295
(* ALT RIGHT *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1296
apply(subst (asm) (2) CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1297
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1298
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1299
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1300
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1301
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1302
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1303
apply (simp add: L_flat_Prf1 Prf_CPrf)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1304
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1305
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1306
apply(rule val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1307
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1308
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1309
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1310
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1311
apply(drule_tac x="v2a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1312
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1313
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1314
apply(subst (asm) val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1315
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1316
apply(subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1317
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1318
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1319
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1320
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1321
apply(rule_tac x="1#p" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1322
apply(rule val_ord_ALTI2)
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
using Posix1(2) apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1325
apply (simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1326
apply(subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1327
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1328
apply(rule val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1329
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1330
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1331
(* STAR empty case *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1332
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1333
apply(subst (asm) CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1334
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1335
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1336
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1337
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1338
apply (simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1339
(* STAR non-empty case *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1340
apply(subst (asm) (3) CPTpre_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1341
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1342
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1343
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1344
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1345
apply (simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1346
apply(rule val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1347
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1348
apply(case_tac "s' = []")
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1349
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1350
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1351
apply (simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1352
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1353
apply(rule val_ord_shorterI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1354
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1355
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
  1356
apply(drule_tac x="va" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1357
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1358
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1359
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
  1360
apply (subst (asm) (2) val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1361
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1362
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1363
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1364
apply(drule_tac x="Stars vsa" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1365
apply(drule meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1366
apply(auto simp add: CPTpre_def)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1367
apply (simp add: Posix1(2))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1368
apply (subst (asm) val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1369
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1370
apply (subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1371
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1372
apply (subst 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 (subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1375
apply(case_tac p)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1376
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1377
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
  1378
using Posix1(2) val_ord_STARI2 apply fastforce
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1379
apply(simp add: val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1380
apply (subst (asm) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1381
apply(erule exE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1382
apply (subst val_ord_ex1_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1383
apply(rule disjI1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1384
apply (subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1385
by (metis Posix1(2) flat.simps(7) flat_Stars val_ord_STARI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1386
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1387
lemma Posix_val_ord_stronger:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1388
  assumes "s \<in> r \<rightarrow> v1" "v2 \<in> CPT r s" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1389
  shows "v1 :\<sqsubseteq>val v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1390
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1391
apply(rule_tac Posix_val_ord)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1392
apply(assumption)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1393
apply(simp add: CPTpre_def CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1394
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1395
246
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1396
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1397
lemma STAR_val_ord:
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1398
  assumes "Stars (v1 # vs1) \<sqsubset>val (Suc p # ps) Stars (v2 # vs2)" "flat v1 = flat v2"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1399
  shows "(Stars vs1) \<sqsubset>val (p # ps) (Stars vs2)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1400
using assms(1,2)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1401
apply -
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1402
apply(simp(no_asm)  add: val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1403
apply(rule conjI)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1404
apply(simp add: val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1405
apply(rule conjI)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1406
apply(simp add: val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1407
apply(auto simp add: pflat_len_simps pflat_len_Stars_simps2)[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1408
apply(rule ballI)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1409
apply(rule impI)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1410
apply(simp add: val_ord_def pflat_len_simps pflat_len_Stars_simps2 intlen_append)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1411
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1412
apply(case_tac q)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1413
apply(simp add: val_ord_def pflat_len_simps pflat_len_Stars_simps2 intlen_append)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1414
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1415
apply(erule disjE)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1416
prefer 2
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1417
apply(drule_tac x="Suc a # list" in bspec)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1418
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1419
apply(drule mp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1420
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1421
apply(simp add: val_ord_def pflat_len_simps pflat_len_Stars_simps2 intlen_append)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1422
apply(drule_tac x="Suc a # list" in bspec)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1423
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1424
apply(drule mp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1425
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1426
apply(simp add: val_ord_def pflat_len_simps pflat_len_Stars_simps2 intlen_append)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1427
done
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1428
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1429
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1430
lemma Posix_val_ord_reverse:
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1431
  assumes "s \<in> r \<rightarrow> v1" 
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1432
  shows "\<not>(\<exists>v2 \<in> CPT r s. v2 :\<sqsubset>val v1)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1433
using assms
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1434
apply(induct)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1435
apply(auto)[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1436
apply(simp add: CPT_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1437
apply(simp add: val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1438
apply(erule exE)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1439
apply(simp add: val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1440
apply(auto simp add: pflat_len_simps)[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1441
using Prf_CPrf Prf_elims(4) apply blast
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1442
(* CHAR *)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1443
apply(auto)[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1444
apply(simp add: CPT_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1445
apply(simp add: val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1446
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1447
apply(erule CPrf.cases)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1448
apply(simp_all)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1449
apply(simp add: val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1450
(* ALT *)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1451
apply(auto)[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1452
apply(simp add: CPT_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1453
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1454
apply(erule CPrf.cases)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1455
apply(simp_all)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1456
apply(simp add: val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1457
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1458
apply(case_tac p)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1459
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1460
apply(simp add: val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1461
apply(auto)[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1462
apply(auto simp add: pflat_len_simps)[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1463
using Posix1(2) apply auto[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1464
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1465
using val_ord_ALTE apply blast
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1466
apply(simp add: val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1467
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1468
apply(simp add: val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1469
apply(auto simp add: pflat_len_simps)[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1470
using Posix1(2) apply auto[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1471
apply (metis (mono_tags, lifting) One_nat_def Pos_empty Sulzmann.lexordp_simps(3) Un_iff inlen_bigger less_minus_one_simps(1) mem_Collect_eq not_less pflat_len_simps(3) pflat_len_simps(6) pflat_len_simps(7) zero_less_one)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1472
(* ALT RIGHT case *)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1473
apply(auto)[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1474
apply(simp add: CPT_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1475
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1476
apply(erule CPrf.cases)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1477
apply(simp_all)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1478
apply(simp add: val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1479
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1480
apply (simp add: L_flat_Prf1 Prf_CPrf)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1481
apply(simp add: val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1482
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1483
apply(case_tac p)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1484
apply (simp add: Posix1(2) pflat_len_simps(7) val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1485
using val_ord_ALTE2 apply blast
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1486
(* SEQ case *)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1487
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1488
apply(simp add: CPT_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1489
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1490
apply(erule CPrf.cases)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1491
apply(simp_all)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1492
apply(drule_tac r="r1a" in val_ord_SEQ)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1493
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1494
using Posix1(2) apply auto[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1495
apply (simp add: Prf_CPrf)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1496
apply (simp add: Posix1a)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1497
apply(auto)[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1498
apply(subgoal_tac "length (flat v1a) \<le> length s1")
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1499
prefer 2
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1500
apply (metis L_flat_Prf1 Prf_CPrf append_eq_append_conv_if append_eq_conv_conj drop_eq_Nil)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1501
apply(subst (asm) append_eq_append_conv_if)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1502
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1503
apply (metis (mono_tags, lifting) CPT_def Posix_CPT le_less_linear mem_Collect_eq take_all val_ord_ex_trans val_ord_shorterI)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1504
using Posix1(2) apply auto[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1505
(* STAR case *)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1506
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1507
apply(simp add: CPT_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1508
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1509
apply(erule CPrf.cases)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1510
apply(simp_all)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1511
apply (simp add: Posix1(2))
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1512
apply(subgoal_tac "length (flat va) \<le> length s1")
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1513
prefer 2
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1514
apply (metis L.simps(6) L_flat_Prf1 Prf_CPrf append_eq_append_conv_if append_eq_conv_conj drop_eq_Nil flat_Stars)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1515
apply(subst (asm) append_eq_append_conv_if)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1516
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1517
(* HERE *)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1518
apply(case_tac "flat va = s1")
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1519
prefer 2
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1520
apply(subgoal_tac "v :\<sqsubset>val va")
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1521
prefer 2
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1522
apply (metis Posix1(2) le_less_linear take_all val_ord_shorterI)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1523
apply(rotate_tac 3)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1524
apply(simp add: val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1525
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1526
apply(case_tac p)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1527
apply(simp add: val_ord_def pflat_len_simps)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1528
apply (smt Posix1(2) append_take_drop_id flat_Stars intlen_append)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1529
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1530
prefer 2
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1531
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1532
apply(drule_tac x="va" in spec)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1533
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1534
apply(subst (asm) (2) val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1535
apply(subst (asm) (2) val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1536
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1537
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1538
apply(drule_tac x="Stars vsa" in spec)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1539
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1540
apply(case_tac p)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1541
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1542
apply (metis Posix1(2) flat.simps(7) flat_Stars less_irrefl pflat_len_simps(7) val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1543
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1544
apply(case_tac a)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1545
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1546
apply(subst (asm) val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1547
apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1548
apply(subst (asm) (2) val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1549
apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1550
apply(simp add: pflat_len_Stars_simps)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1551
apply(simp add: pflat_len_simps)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1552
prefer 3
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1553
proof -
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1554
  fix s1 :: "char list" and v :: val and s2 :: "char list" and vs :: "val list" and va :: val and ra :: rexp and vsa :: "val list" and p :: "nat list" and pa :: "nat list" and a :: nat and list :: "nat list"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1555
  assume a1: "length (flat va) \<le> length s1"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1556
  assume a2: "s1 \<in> ra \<rightarrow> v"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1557
  assume a3: "s2 \<in> STAR ra \<rightarrow> Stars vs"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1558
  assume a4: "Stars (va # vsa) \<sqsubset>val a # list Stars (v # vs)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1559
  assume a5: "v \<sqsubset>val pa va"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1560
  assume a6: "flat va = take (length (flat va)) s1"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1561
  assume a7: "concat (map flat vsa) = drop (length (flat va)) s1 @ s2"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1562
  assume "p = a # list"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1563
  obtain nns :: "val \<Rightarrow> val \<Rightarrow> nat list" where
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1564
    f8: "(\<forall>v va. \<not> v :\<sqsubset>val va \<or> v \<sqsubset>val nns v va va) \<and> (\<forall>v va. (\<forall>ns. \<not> v \<sqsubset>val ns va) \<or> v :\<sqsubset>val va)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1565
    using val_ord_ex_def by moura
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1566
  then have "Stars (v # vs) :\<sqsubset>val Stars (va # vsa)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1567
    using a7 a6 a5 a3 a2 a1 by (metis Posix1(2) append_eq_append_conv_if flat.simps(7) flat_Stars val_ord_STARI)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1568
  then show False
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1569
    using f8 a4 by (meson less_irrefl val_ord_def val_ord_ex_trans)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1570
next
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1571
  fix v :: val and vs :: "val list" and va :: val and ra :: rexp and vsa :: "val list" and list :: "nat list"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1572
  assume a1: "intlen (flat va @ concat (map flat vsa)) = intlen (flat v @ concat (map flat vs)) \<and> (\<forall>q\<in>{0 # ps |ps. ps \<in> Pos va} \<union> {Suc n # ps |n ps. n # ps \<in> Pos (Stars vsa)} \<union> ({0 # ps |ps. ps \<in> Pos v} \<union> {Suc n # ps |n ps. n # ps \<in> Pos (Stars vs)}). q \<sqsubset>lex 0 # list \<longrightarrow> pflat_len (Stars (va # vsa)) q = pflat_len (Stars (v # vs)) q)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1573
  assume a2: "pflat_len v list < pflat_len va list"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1574
  assume a3: "list \<in> Pos va"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1575
  assume a4: "\<forall>p. \<not> va \<sqsubset>val p v"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1576
  have f5: "\<And>ns. pflat_len (Stars (v # vs)) ns = pflat_len (Stars (va # vsa)) ns \<or> \<not> ns \<sqsubset>lex 0 # list \<or> (\<forall>nsa. ns \<noteq> 0 # nsa \<or> nsa \<notin> Pos v)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1577
    using a1 by fastforce
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1578
  have "\<And>ns. pflat_len (Stars (v # vs)) ns = pflat_len (Stars (va # vsa)) ns \<or> \<not> ns \<sqsubset>lex 0 # list \<or> (\<forall>nsa. ns \<noteq> 0 # nsa \<or> nsa \<notin> Pos va)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1579
    using a1 by fastforce
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1580
  then show False
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1581
    using f5 a4 a3 a2 by (metis (no_types) Sulzmann.lexordp_simps(3) Un_iff pflat_len_Stars_simps2(2) val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1582
next
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1583
  fix v abd vs and va and ra and vsa and p a and list and nat
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1584
  assume "flat va \<in> ra \<rightarrow> v"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1585
         "concat (map flat vsa) \<in> STAR ra \<rightarrow> Stars vs" "flat v \<noteq> []"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1586
         "\<forall>s\<^sub>3. flat va @ s\<^sub>3 \<in> L ra \<longrightarrow> s\<^sub>3 = [] \<or> (\<forall>s\<^sub>4. s\<^sub>3 @ s\<^sub>4 = concat (map flat vsa) \<longrightarrow> s\<^sub>4 \<notin> L ra\<star>)"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1587
         "\<Turnstile> va : ra" "flat va \<noteq> []"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1588
         "\<Turnstile> Stars vsa : STAR ra" 
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1589
         "\<forall>p. \<not> va \<sqsubset>val p v" "Stars (va # vsa) \<sqsubset>val a # list Stars (v # vs)" 
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1590
         "\<not> Stars vsa :\<sqsubset>val Stars vs" "a = Suc nat"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1591
  then show "False"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1592
  apply -
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1593
  apply(subst (asm) val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1594
  apply(simp)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1595
  apply(drule STAR_val_ord)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1596
  using Posix1(2) apply auto[1]
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1597
  apply blast
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1598
  done
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1599
next
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1600
  fix r
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1601
  show " \<forall>v2\<in>CPT (STAR r) []. \<not> v2 :\<sqsubset>val Stars []"
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1602
  apply -
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1603
  apply(rule ballI)    
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1604
  apply(simp add: CPT_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1605
  apply(auto)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1606
  apply(erule CPrf.cases)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1607
  apply(simp_all)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1608
  apply(simp add: val_ord_ex_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1609
  apply(clarify)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1610
  apply(simp add: val_ord_def)
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1611
  done
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1612
qed  
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1613
23657fad2017 updated
Christian Urban <urbanc@in.tum.de>
parents: 245
diff changeset
  1614
245
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1615
definition Minval :: "rexp \<Rightarrow> string \<Rightarrow> val \<Rightarrow> bool"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1616
  where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1617
  "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
  1618
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1619
lemma 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1620
  assumes "s \<in> L(r)"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1621
  shows "\<exists>v. Minval r s v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1622
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1623
apply(induct r arbitrary: s)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1624
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1625
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1626
apply(rule_tac x="Void" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1627
apply(simp add: Minval_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1628
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1629
apply (simp add: CPrf.intros(4))
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1630
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1631
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1632
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1633
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1634
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1635
apply(rule_tac x="Char x" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1636
apply(simp add: Minval_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1637
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1638
apply (simp add: CPrf.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1639
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1640
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1641
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1642
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1643
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1644
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1645
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1646
apply(drule_tac x="s" in meta_spec) 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1647
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1648
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1649
apply(rule_tac x="Left x" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1650
apply(simp (no_asm) add: Minval_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1651
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1652
apply (simp add: CPrf.intros(2) Minval_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1653
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1654
apply(simp add: Minval_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1655
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1656
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1657
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1658
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1659
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1660
apply(simp add: val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1661
apply(simp only: val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1662
oops
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1663
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1664
lemma
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1665
  "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
  1666
apply(rule wfI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1667
oops
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1668
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1669
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
  1670
where
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1671
  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
  1672
| 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
  1673
| 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
  1674
| 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
  1675
| 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
  1676
| 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
  1677
| 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
  1678
| 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
  1679
| 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
  1680
| 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
  1681
| MY1: "Void \<preceq>ONE Void" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1682
| MY2: "(Char c) \<preceq>(CHAR c) (Char c)" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1683
| MY3: "(Stars []) \<preceq>(STAR r) (Stars [])" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1684
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1685
lemma ValOrd_refl: 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1686
  assumes "\<turnstile> v : r" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1687
  shows "v \<preceq>r v"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1688
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1689
apply(induct r rule: Prf.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1690
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1691
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1692
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1693
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1694
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1695
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1696
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1697
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1698
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1699
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1700
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1701
done
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1702
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1703
lemma Posix_CPT2:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1704
  assumes "v1 \<preceq>r v2" "flat v1 = flat v2"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1705
  shows "v2 :\<sqsubset>val v1 \<or> v1 = v2" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1706
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1707
apply(induct r arbitrary: v1 v2 rule: rexp.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1708
apply(erule ValOrd.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1709
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1710
apply(erule ValOrd.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1711
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1712
apply(erule ValOrd.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1713
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1714
apply(erule ValOrd.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1715
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1716
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1717
(* HERE *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1718
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1719
apply(subst val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1720
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1721
apply(drule_tac x="v2a" in  meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1722
apply(rotate_tac 5)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1723
apply(drule_tac x="v2'" in  meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1724
apply(rule_tac x="0#p" in exI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1725
apply(rule val_ord_SEQI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1726
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1727
apply(drule_tac r="r1a" in  val_ord_SEQ)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1728
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1729
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1730
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1731
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1732
lemma Posix_CPT:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1733
  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
  1734
  shows "v1 \<preceq>r v2" 
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1735
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1736
apply(induct r arbitrary: v1 v2 s rule: rexp.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1737
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1738
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1739
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1740
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1741
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1742
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1743
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1744
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1745
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1746
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1747
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1748
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1749
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1750
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1751
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1752
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1753
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1754
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1755
(*SEQ case *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1756
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1757
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1758
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1759
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1760
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1761
apply(erule CPrf.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1762
apply(simp_all)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1763
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1764
thm val_ord_SEQ
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1765
apply(drule_tac r="r1a" in  val_ord_SEQ)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1766
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1767
using Prf_CPrf apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1768
using Prf_CPrf apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1769
apply(erule disjE)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1770
apply(rule C2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1771
prefer 2
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1772
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1773
apply(rule C1)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1774
apply blast
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1775
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1776
apply(simp add: append_eq_append_conv2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1777
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1778
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1779
apply(drule_tac x="v1a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1780
apply(rotate_tac 8)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1781
apply(drule_tac x="v1b" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1782
apply(rotate_tac 8)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1783
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1784
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1785
(* HERE *)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1786
apply(subst (asm) (3) val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1787
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1788
apply(subst (asm) val_ord_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1789
apply(clarify)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1790
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1791
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1792
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1793
apply(simp add: val_ord_ex_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1794
oops
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1795
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1796
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1797
lemma ValOrd_trans:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1798
  assumes "x \<preceq>r y" "y \<preceq>r z"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1799
  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
  1800
  shows "x \<preceq>r z"
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1801
using assms
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1802
apply(induct x r y arbitrary: s z rule: ValOrd.induct)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1803
apply(rotate_tac 2)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1804
apply(erule ValOrd.cases)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1805
apply(simp_all)[13]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1806
apply(rule ValOrd.intros)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1807
apply(drule_tac x="s" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1808
apply(drule_tac x="v1'a" in meta_spec)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1809
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1810
apply(simp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1811
apply(drule_tac meta_mp)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1812
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1813
oops
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1814
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1815
lemma ValOrd_preorder:
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1816
  "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
  1817
apply(simp add: preorder_on_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1818
apply(rule conjI)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1819
apply(simp add: refl_on_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1820
apply(auto)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1821
apply(rule ValOrd_refl)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1822
apply(simp add: CPT_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1823
apply(rule Prf_CPrf)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1824
apply(auto)[1]
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1825
apply(simp add: trans_def)
b16702bb6242 updated
Christian Urban <urbanc@in.tum.de>
parents: 204
diff changeset
  1826
apply(auto)
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1827
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1828
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
  1829
where 
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1830
  "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
  1831
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1832
(*
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1833
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1834
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1835
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
  1836
where
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1837
  "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
  1838
| "\<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
  1839
| "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
  1840
| "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
  1841
| "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
  1842
| "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
  1843
| "Void \<succ>EMPTY Void"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1844
| "(Char c) \<succ>(CHAR c) (Char c)"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1845
| "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
  1846
| "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
  1847
| "\<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
  1848
| "(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
  1849
| "(Stars []) \<succ>(STAR r) (Stars [])"
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1850
*)
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1851
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1852
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1853
section {* Bit-Encodings *}
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1854
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1855
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1856
fun 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1857
  code :: "val \<Rightarrow> rexp \<Rightarrow> bool list"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1858
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1859
  "code Void ONE = []"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1860
| "code (Char c) (CHAR d) = []"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1861
| "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
  1862
| "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
  1863
| "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
  1864
| "code (Stars []) (STAR r) = [True]"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1865
| "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
  1866
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1867
fun 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1868
  Stars_add :: "val \<Rightarrow> val \<Rightarrow> val"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1869
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1870
  "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
  1871
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1872
function
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1873
  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
  1874
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1875
  "decode' ds ZERO = (Void, [])"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1876
| "decode' ds ONE = (Void, ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1877
| "decode' ds (CHAR d) = (Char d, ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1878
| "decode' [] (ALT r1 r2) = (Void, [])"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1879
| "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
  1880
| "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
  1881
| "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
  1882
                             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
  1883
| "decode' [] (STAR r) = (Void, [])"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1884
| "decode' (True # ds) (STAR r) = (Stars [], ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1885
| "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
  1886
                                    let (vs, ds'') = decode' ds' (STAR r) 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1887
                                    in (Stars_add v vs, ds''))"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1888
by pat_completeness auto
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1889
204
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1890
termination
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1891
apply(size_change)
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1892
oops
cd9e40280784 added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
  1893
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1894
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
  1895
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1896
lemma decode'_smaller:
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1897
  assumes "decode'_dom (ds, r)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1898
  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
  1899
using assms
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1900
apply(induct ds r)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1901
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
  1902
using dual_order.trans apply blast
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1903
by (meson dual_order.trans le_SucI)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1904
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1905
termination "decode'"  
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1906
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
  1907
apply(auto dest!: decode'_smaller)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1908
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
  1909
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1910
fun 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1911
  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
  1912
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1913
  "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
  1914
                  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
  1915
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1916
lemma decode'_code:
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1917
  assumes "\<turnstile> v : r"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1918
  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
  1919
using assms
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1920
by (induct v r arbitrary: ds) (auto)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1921
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1922
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1923
lemma decode_code:
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1924
  assumes "\<turnstile> v : r"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1925
  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
  1926
using assms decode'_code[of _ _ "[]"]
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1927
by auto
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
  1928
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1929
datatype arexp =
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1930
  AZERO
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1931
| AONE "bool list"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1932
| ACHAR "bool list" char
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1933
| ASEQ "bool list" arexp arexp
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1934
| AALT "bool list" arexp arexp
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1935
| ASTAR "bool list" arexp
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1936
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1937
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
  1938
  "fuse bs AZERO = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1939
| "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
  1940
| "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
  1941
| "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
  1942
| "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
  1943
| "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
  1944
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1945
fun internalise :: "rexp \<Rightarrow> arexp" where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1946
  "internalise ZERO = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1947
| "internalise ONE = AONE []"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1948
| "internalise (CHAR c) = ACHAR [] c"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1949
| "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
  1950
                                     (fuse [True]  (internalise r2))"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1951
| "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
  1952
| "internalise (STAR r) = ASTAR [] (internalise r)"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1953
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1954
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
  1955
  "retrieve (AONE bs) Void = bs"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1956
| "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
  1957
| "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
  1958
| "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
  1959
| "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
  1960
| "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
  1961
| "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
  1962
     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
  1963
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1964
fun
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1965
 anullable :: "arexp \<Rightarrow> bool"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1966
where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1967
  "anullable (AZERO) = False"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1968
| "anullable (AONE bs) = True"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1969
| "anullable (ACHAR bs c) = False"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1970
| "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
  1971
| "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
  1972
| "anullable (ASTAR bs r) = True"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1973
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1974
fun 
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1975
  amkeps :: "arexp \<Rightarrow> bool list"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1976
where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1977
  "amkeps(AONE bs) = bs"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1978
| "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
  1979
| "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
  1980
| "amkeps(ASTAR bs r) = bs @ [True]"
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1981
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1982
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1983
fun
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1984
 ader :: "char \<Rightarrow> arexp \<Rightarrow> arexp"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1985
where
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1986
  "ader c (AZERO) = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1987
| "ader c (AONE bs) = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1988
| "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
  1989
| "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
  1990
| "ader c (ASEQ bs r1 r2) = 
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1991
     (if anullable r1
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1992
      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
  1993
      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
  1994
| "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
  1995
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1996
lemma
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1997
  assumes "\<turnstile> v : der c r"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  1998
  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
  1999
using assms
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2000
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
  2001
apply(simp_all)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2002
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2003
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2004
apply(case_tac "c = d")
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2005
apply(simp)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2006
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2007
apply(simp)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2008
apply(simp)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2009
apply(erule Prf_elims)
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2010
apply(auto split: prod.splits)[1]
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2011
oops
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
  2012
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2013
end