thys3/Positions.thy
author Chengsong
Mon, 04 Jul 2022 12:27:13 +0100
changeset 558 671a83abccf3
parent 495 f9cdc295ccf7
permissions -rw-r--r--
haha
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
   
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
theory Positions
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
  imports PosixSpec Lexer
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
begin
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
chapter \<open>An alternative definition for POSIX values\<close>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
section \<open>Positions in Values\<close>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
fun 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
  at :: "val \<Rightarrow> nat list \<Rightarrow> val"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
  "at v [] = v"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
| "at (Left v) (0#ps)= at v ps"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
| "at (Right v) (Suc 0#ps)= at v ps"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
| "at (Seq v1 v2) (0#ps)= at v1 ps"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
| "at (Seq v1 v2) (Suc 0#ps)= at v2 ps"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
| "at (Stars vs) (n#ps)= at (nth vs n) ps"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22
fun Pos :: "val \<Rightarrow> (nat list) set"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    23
where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
  "Pos (Void) = {[]}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
| "Pos (Char c) = {[]}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
| "Pos (Left v) = {[]} \<union> {0#ps | ps. ps \<in> Pos v}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    27
| "Pos (Right v) = {[]} \<union> {1#ps | ps. ps \<in> Pos v}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    28
| "Pos (Seq v1 v2) = {[]} \<union> {0#ps | ps. ps \<in> Pos v1} \<union> {1#ps | ps. ps \<in> Pos v2}" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    29
| "Pos (Stars []) = {[]}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
| "Pos (Stars (v#vs)) = {[]} \<union> {0#ps | ps. ps \<in> Pos v} \<union> {Suc n#ps | n ps. n#ps \<in> Pos (Stars vs)}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    31
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    32
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    33
lemma Pos_stars:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    34
  "Pos (Stars vs) = {[]} \<union> (\<Union>n < length vs. {n#ps | ps. ps \<in> Pos (vs ! n)})"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    35
apply(induct vs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
apply(auto simp add: insert_ident less_Suc_eq_0_disj)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    37
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    38
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
lemma Pos_empty:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    40
  shows "[] \<in> Pos v"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    41
by (induct v rule: Pos.induct)(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    42
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    43
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    44
abbreviation
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    45
  "intlen vs \<equiv> int (length vs)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    46
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    47
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    48
definition pflat_len :: "val \<Rightarrow> nat list => int"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    49
where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    50
  "pflat_len v p \<equiv> (if p \<in> Pos v then intlen (flat (at v p)) else -1)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    51
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    52
lemma pflat_len_simps:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    53
  shows "pflat_len (Seq v1 v2) (0#p) = pflat_len v1 p"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    54
  and   "pflat_len (Seq v1 v2) (Suc 0#p) = pflat_len v2 p"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    55
  and   "pflat_len (Left v) (0#p) = pflat_len v p"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    56
  and   "pflat_len (Left v) (Suc 0#p) = -1"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    57
  and   "pflat_len (Right v) (Suc 0#p) = pflat_len v p"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    58
  and   "pflat_len (Right v) (0#p) = -1"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    59
  and   "pflat_len (Stars (v#vs)) (Suc n#p) = pflat_len (Stars vs) (n#p)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    60
  and   "pflat_len (Stars (v#vs)) (0#p) = pflat_len v p"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    61
  and   "pflat_len v [] = intlen (flat v)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    62
by (auto simp add: pflat_len_def Pos_empty)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    63
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    64
lemma pflat_len_Stars_simps:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    65
  assumes "n < length vs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    66
  shows "pflat_len (Stars vs) (n#p) = pflat_len (vs!n) p"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    67
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    68
apply(induct vs arbitrary: n p)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    69
apply(auto simp add: less_Suc_eq_0_disj pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    70
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    71
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    72
lemma pflat_len_outside:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    73
  assumes "p \<notin> Pos v1"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    74
  shows "pflat_len v1 p = -1 "
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    75
using assms by (simp add: pflat_len_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    76
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    77
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    78
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    79
section \<open>Orderings\<close>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    80
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    81
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    82
definition prefix_list:: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<sqsubseteq>pre _" [60,59] 60)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    83
where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    84
  "ps1 \<sqsubseteq>pre ps2 \<equiv> \<exists>ps'. ps1 @ps' = ps2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    85
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    86
definition sprefix_list:: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<sqsubset>spre _" [60,59] 60)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    87
where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    88
  "ps1 \<sqsubset>spre ps2 \<equiv> ps1 \<sqsubseteq>pre ps2 \<and> ps1 \<noteq> ps2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    89
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    90
inductive lex_list :: "nat list \<Rightarrow> nat list \<Rightarrow> bool" ("_ \<sqsubset>lex _" [60,59] 60)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    91
where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    92
  "[] \<sqsubset>lex (p#ps)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    93
| "ps1 \<sqsubset>lex ps2 \<Longrightarrow> (p#ps1) \<sqsubset>lex (p#ps2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    94
| "p1 < p2 \<Longrightarrow> (p1#ps1) \<sqsubset>lex (p2#ps2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    95
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    96
lemma lex_irrfl:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    97
  fixes ps1 ps2 :: "nat list"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    98
  assumes "ps1 \<sqsubset>lex ps2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    99
  shows "ps1 \<noteq> ps2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   100
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   101
by(induct rule: lex_list.induct)(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   102
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   103
lemma lex_simps [simp]:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   104
  fixes xs ys :: "nat list"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   105
  shows "[] \<sqsubset>lex ys \<longleftrightarrow> ys \<noteq> []"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   106
  and   "xs \<sqsubset>lex [] \<longleftrightarrow> False"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   107
  and   "(x # xs) \<sqsubset>lex (y # ys) \<longleftrightarrow> (x < y \<or> (x = y \<and> xs \<sqsubset>lex ys))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   108
by (auto simp add: neq_Nil_conv elim: lex_list.cases intro: lex_list.intros)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   109
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   110
lemma lex_trans:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   111
  fixes ps1 ps2 ps3 :: "nat list"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   112
  assumes "ps1 \<sqsubset>lex ps2" "ps2 \<sqsubset>lex ps3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   113
  shows "ps1 \<sqsubset>lex ps3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   114
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   115
by (induct arbitrary: ps3 rule: lex_list.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   116
   (auto elim: lex_list.cases)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   117
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   118
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   119
lemma lex_trichotomous:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   120
  fixes p q :: "nat list"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   121
  shows "p = q \<or> p \<sqsubset>lex q \<or> q \<sqsubset>lex p"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   122
apply(induct p arbitrary: q)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   123
apply(auto elim: lex_list.cases)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   124
apply(case_tac q)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   125
apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   126
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   127
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   128
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   129
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   130
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   131
section \<open>POSIX Ordering of Values According to Okui \& Suzuki\<close>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   132
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   133
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   134
definition PosOrd:: "val \<Rightarrow> nat list \<Rightarrow> val \<Rightarrow> bool" ("_ \<sqsubset>val _ _" [60, 60, 59] 60)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   135
where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   136
  "v1 \<sqsubset>val p v2 \<equiv> pflat_len v1 p > pflat_len v2 p \<and>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   137
                   (\<forall>q \<in> Pos v1 \<union> Pos v2. q \<sqsubset>lex p \<longrightarrow> pflat_len v1 q = pflat_len v2 q)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   138
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   139
lemma PosOrd_def2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   140
  shows "v1 \<sqsubset>val p v2 \<longleftrightarrow> 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   141
         pflat_len v1 p > pflat_len v2 p \<and>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   142
         (\<forall>q \<in> Pos v1. q \<sqsubset>lex p \<longrightarrow> pflat_len v1 q = pflat_len v2 q) \<and>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   143
         (\<forall>q \<in> Pos v2. q \<sqsubset>lex p \<longrightarrow> pflat_len v1 q = pflat_len v2 q)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   144
unfolding PosOrd_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   145
apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   146
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   147
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   148
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   149
definition PosOrd_ex:: "val \<Rightarrow> val \<Rightarrow> bool" ("_ :\<sqsubset>val _" [60, 59] 60)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   150
where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   151
  "v1 :\<sqsubset>val v2 \<equiv> \<exists>p. v1 \<sqsubset>val p v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   152
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   153
definition PosOrd_ex_eq:: "val \<Rightarrow> val \<Rightarrow> bool" ("_ :\<sqsubseteq>val _" [60, 59] 60)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   154
where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   155
  "v1 :\<sqsubseteq>val v2 \<equiv> v1 :\<sqsubset>val v2 \<or> v1 = v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   156
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   157
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   158
lemma PosOrd_trans:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   159
  assumes "v1 :\<sqsubset>val v2" "v2 :\<sqsubset>val v3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   160
  shows "v1 :\<sqsubset>val v3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   161
proof -
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   162
  from assms obtain p p'
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   163
    where as: "v1 \<sqsubset>val p v2" "v2 \<sqsubset>val p' v3" unfolding PosOrd_ex_def by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   164
  then have pos: "p \<in> Pos v1" "p' \<in> Pos v2" unfolding PosOrd_def pflat_len_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   165
    by (smt not_int_zless_negative)+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   166
  have "p = p' \<or> p \<sqsubset>lex p' \<or> p' \<sqsubset>lex p"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   167
    by (rule lex_trichotomous)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   168
  moreover
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   169
    { assume "p = p'"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   170
      with as have "v1 \<sqsubset>val p v3" unfolding PosOrd_def pflat_len_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   171
      by (smt Un_iff)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   172
      then have " v1 :\<sqsubset>val v3" unfolding PosOrd_ex_def by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   173
    }   
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   174
  moreover
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   175
    { assume "p \<sqsubset>lex p'"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   176
      with as have "v1 \<sqsubset>val p v3" unfolding PosOrd_def pflat_len_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   177
      by (smt Un_iff lex_trans)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   178
      then have " v1 :\<sqsubset>val v3" unfolding PosOrd_ex_def by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   179
    }
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   180
  moreover
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   181
    { assume "p' \<sqsubset>lex p"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   182
      with as have "v1 \<sqsubset>val p' v3" unfolding PosOrd_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   183
      by (smt Un_iff lex_trans pflat_len_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   184
      then have "v1 :\<sqsubset>val v3" unfolding PosOrd_ex_def by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   185
    }
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   186
  ultimately show "v1 :\<sqsubset>val v3" by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   187
qed
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   188
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   189
lemma PosOrd_irrefl:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   190
  assumes "v :\<sqsubset>val v"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   191
  shows "False"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   192
using assms unfolding PosOrd_ex_def PosOrd_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   193
by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   194
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   195
lemma PosOrd_assym:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   196
  assumes "v1 :\<sqsubset>val v2" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   197
  shows "\<not>(v2 :\<sqsubset>val v1)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   198
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   199
using PosOrd_irrefl PosOrd_trans by blast 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   200
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   201
(*
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   202
  :\<sqsubseteq>val and :\<sqsubset>val are partial orders.
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   203
*)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   204
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   205
lemma PosOrd_ordering:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   206
  shows "ordering (\<lambda>v1 v2. v1 :\<sqsubseteq>val v2) (\<lambda> v1 v2. v1 :\<sqsubset>val v2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   207
unfolding ordering_def PosOrd_ex_eq_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   208
apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   209
using PosOrd_trans partial_preordering_def apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   210
using PosOrd_assym ordering_axioms_def by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   211
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   212
lemma PosOrd_order:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   213
  shows "class.order (\<lambda>v1 v2. v1 :\<sqsubseteq>val v2) (\<lambda> v1 v2. v1 :\<sqsubset>val v2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   214
using PosOrd_ordering
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   215
apply(simp add: class.order_def class.preorder_def class.order_axioms_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   216
  by (metis (full_types) PosOrd_ex_eq_def PosOrd_irrefl PosOrd_trans)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   217
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   218
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   219
lemma PosOrd_ex_eq2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   220
  shows "v1 :\<sqsubset>val v2 \<longleftrightarrow> (v1 :\<sqsubseteq>val v2 \<and> v1 \<noteq> v2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   221
  using PosOrd_ordering
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   222
  using PosOrd_ex_eq_def PosOrd_irrefl by blast 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   223
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   224
lemma PosOrdeq_trans:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   225
  assumes "v1 :\<sqsubseteq>val v2" "v2 :\<sqsubseteq>val v3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   226
  shows "v1 :\<sqsubseteq>val v3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   227
using assms PosOrd_ordering 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   228
  unfolding ordering_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   229
  by (metis partial_preordering.trans)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   230
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   231
lemma PosOrdeq_antisym:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   232
  assumes "v1 :\<sqsubseteq>val v2" "v2 :\<sqsubseteq>val v1"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   233
  shows "v1 = v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   234
using assms PosOrd_ordering 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   235
  unfolding ordering_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   236
  by (simp add: ordering_axioms_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   237
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   238
lemma PosOrdeq_refl:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   239
  shows "v :\<sqsubseteq>val v" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   240
unfolding PosOrd_ex_eq_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   241
by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   242
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   243
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   244
lemma PosOrd_shorterE:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   245
  assumes "v1 :\<sqsubset>val v2" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   246
  shows "length (flat v2) \<le> length (flat v1)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   247
using assms unfolding PosOrd_ex_def PosOrd_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   248
apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   249
apply(case_tac p)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   250
apply(simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   251
apply(drule_tac x="[]" in bspec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   252
apply(simp add: Pos_empty)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   253
apply(simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   254
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   255
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   256
lemma PosOrd_shorterI:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   257
  assumes "length (flat v2) < length (flat v1)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   258
  shows "v1 :\<sqsubset>val v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   259
unfolding PosOrd_ex_def PosOrd_def pflat_len_def 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   260
using assms Pos_empty by force
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   261
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   262
lemma PosOrd_spreI:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   263
  assumes "flat v' \<sqsubset>spre flat v"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   264
  shows "v :\<sqsubset>val v'" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   265
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   266
apply(rule_tac PosOrd_shorterI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   267
unfolding prefix_list_def sprefix_list_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   268
by (metis append_Nil2 append_eq_conv_conj drop_all le_less_linear)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   269
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   270
lemma pflat_len_inside:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   271
  assumes "pflat_len v2 p < pflat_len v1 p"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   272
  shows "p \<in> Pos v1"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   273
using assms 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   274
unfolding pflat_len_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   275
by (auto split: if_splits)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   276
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   277
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   278
lemma PosOrd_Left_Right:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   279
  assumes "flat v1 = flat v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   280
  shows "Left v1 :\<sqsubset>val Right v2" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   281
unfolding PosOrd_ex_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   282
apply(rule_tac x="[0]" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   283
apply(auto simp add: PosOrd_def pflat_len_simps assms)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   284
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   285
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   286
lemma PosOrd_LeftE:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   287
  assumes "Left v1 :\<sqsubset>val Left v2" "flat v1 = flat v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   288
  shows "v1 :\<sqsubset>val v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   289
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   290
unfolding PosOrd_ex_def PosOrd_def2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   291
apply(auto simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   292
apply(frule pflat_len_inside)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   293
apply(auto simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   294
by (metis lex_simps(3) pflat_len_simps(3))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   295
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   296
lemma PosOrd_LeftI:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   297
  assumes "v1 :\<sqsubset>val v2" "flat v1 = flat v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   298
  shows  "Left v1 :\<sqsubset>val Left v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   299
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   300
unfolding PosOrd_ex_def PosOrd_def2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   301
apply(auto simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   302
by (metis less_numeral_extra(3) lex_simps(3) pflat_len_simps(3))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   303
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   304
lemma PosOrd_Left_eq:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   305
  assumes "flat v1 = flat v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   306
  shows "Left v1 :\<sqsubset>val Left v2 \<longleftrightarrow> v1 :\<sqsubset>val v2" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   307
using assms PosOrd_LeftE PosOrd_LeftI
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   308
by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   309
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   310
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   311
lemma PosOrd_RightE:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   312
  assumes "Right v1 :\<sqsubset>val Right v2" "flat v1 = flat v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   313
  shows "v1 :\<sqsubset>val v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   314
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   315
unfolding PosOrd_ex_def PosOrd_def2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   316
apply(auto simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   317
apply(frule pflat_len_inside)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   318
apply(auto simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   319
by (metis lex_simps(3) pflat_len_simps(5))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   320
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   321
lemma PosOrd_RightI:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   322
  assumes "v1 :\<sqsubset>val v2" "flat v1 = flat v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   323
  shows  "Right v1 :\<sqsubset>val Right v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   324
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   325
unfolding PosOrd_ex_def PosOrd_def2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   326
apply(auto simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   327
by (metis lex_simps(3) nat_neq_iff pflat_len_simps(5))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   328
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   329
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   330
lemma PosOrd_Right_eq:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   331
  assumes "flat v1 = flat v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   332
  shows "Right v1 :\<sqsubset>val Right v2 \<longleftrightarrow> v1 :\<sqsubset>val v2" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   333
using assms PosOrd_RightE PosOrd_RightI
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   334
by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   335
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   336
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   337
lemma PosOrd_SeqI1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   338
  assumes "v1 :\<sqsubset>val w1" "flat (Seq v1 v2) = flat (Seq w1 w2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   339
  shows "Seq v1 v2 :\<sqsubset>val Seq w1 w2" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   340
using assms(1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   341
apply(subst (asm) PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   342
apply(subst (asm) PosOrd_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   343
apply(clarify)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   344
apply(subst PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   345
apply(rule_tac x="0#p" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   346
apply(subst PosOrd_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   347
apply(rule conjI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   348
apply(simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   349
apply(rule ballI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   350
apply(rule impI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   351
apply(simp only: Pos.simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   352
apply(auto)[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   353
apply(simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   354
apply(auto simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   355
using assms(2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   356
apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   357
apply(metis length_append of_nat_add)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   358
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   359
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   360
lemma PosOrd_SeqI2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   361
  assumes "v2 :\<sqsubset>val w2" "flat v2 = flat w2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   362
  shows "Seq v v2 :\<sqsubset>val Seq v w2" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   363
using assms(1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   364
apply(subst (asm) PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   365
apply(subst (asm) PosOrd_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   366
apply(clarify)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   367
apply(subst PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   368
apply(rule_tac x="Suc 0#p" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   369
apply(subst PosOrd_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   370
apply(rule conjI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   371
apply(simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   372
apply(rule ballI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   373
apply(rule impI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   374
apply(simp only: Pos.simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   375
apply(auto)[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   376
apply(simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   377
using assms(2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   378
apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   379
apply(auto simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   380
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   381
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   382
lemma PosOrd_Seq_eq:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   383
  assumes "flat v2 = flat w2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   384
  shows "(Seq v v2) :\<sqsubset>val (Seq v w2) \<longleftrightarrow> v2 :\<sqsubset>val w2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   385
using assms 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   386
apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   387
prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   388
apply(simp add: PosOrd_SeqI2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   389
apply(simp add: PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   390
apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   391
apply(case_tac p)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   392
apply(simp add: PosOrd_def pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   393
apply(case_tac a)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   394
apply(simp add: PosOrd_def pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   395
apply(clarify)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   396
apply(case_tac nat)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   397
prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   398
apply(simp add: PosOrd_def pflat_len_simps pflat_len_outside)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   399
apply(rule_tac x="list" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   400
apply(auto simp add: PosOrd_def2 pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   401
apply(smt Collect_disj_eq lex_list.intros(2) mem_Collect_eq pflat_len_simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   402
apply(smt Collect_disj_eq lex_list.intros(2) mem_Collect_eq pflat_len_simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   403
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   404
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   405
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   406
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   407
lemma PosOrd_StarsI:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   408
  assumes "v1 :\<sqsubset>val v2" "flats (v1#vs1) = flats (v2#vs2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   409
  shows "Stars (v1#vs1) :\<sqsubset>val Stars (v2#vs2)" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   410
using assms(1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   411
apply(subst (asm) PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   412
apply(subst (asm) PosOrd_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   413
apply(clarify)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   414
apply(subst PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   415
apply(subst PosOrd_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   416
apply(rule_tac x="0#p" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   417
apply(simp add: pflat_len_Stars_simps pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   418
using assms(2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   419
apply(simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   420
apply(auto simp add: pflat_len_Stars_simps pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   421
by (metis length_append of_nat_add)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   422
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   423
lemma PosOrd_StarsI2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   424
  assumes "Stars vs1 :\<sqsubset>val Stars vs2" "flats vs1 = flats vs2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   425
  shows "Stars (v#vs1) :\<sqsubset>val Stars (v#vs2)" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   426
using assms(1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   427
apply(subst (asm) PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   428
apply(subst (asm) PosOrd_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   429
apply(clarify)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   430
apply(subst PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   431
apply(subst PosOrd_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   432
apply(case_tac p)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   433
apply(simp add: pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   434
apply(rule_tac x="Suc a#list" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   435
apply(auto simp add: pflat_len_Stars_simps pflat_len_simps assms(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   436
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   437
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   438
lemma PosOrd_Stars_appendI:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   439
  assumes "Stars vs1 :\<sqsubset>val Stars vs2" "flat (Stars vs1) = flat (Stars vs2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   440
  shows "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   441
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   442
apply(induct vs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   443
apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   444
apply(simp add: PosOrd_StarsI2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   445
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   446
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   447
lemma PosOrd_StarsE2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   448
  assumes "Stars (v # vs1) :\<sqsubset>val Stars (v # vs2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   449
  shows "Stars vs1 :\<sqsubset>val Stars vs2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   450
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   451
apply(subst (asm) PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   452
apply(erule exE)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   453
apply(case_tac p)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   454
apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   455
apply(simp add: PosOrd_def pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   456
apply(subst PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   457
apply(rule_tac x="[]" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   458
apply(simp add: PosOrd_def pflat_len_simps Pos_empty)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   459
apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   460
apply(case_tac a)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   461
apply(clarify)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   462
apply(auto simp add: pflat_len_simps PosOrd_def pflat_len_def split: if_splits)[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   463
apply(clarify)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   464
apply(simp add: PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   465
apply(rule_tac x="nat#list" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   466
apply(auto simp add: PosOrd_def pflat_len_simps)[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   467
apply(case_tac q)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   468
apply(simp add: PosOrd_def pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   469
apply(clarify)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   470
apply(drule_tac x="Suc a # lista" in bspec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   471
apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   472
apply(auto simp add: PosOrd_def pflat_len_simps)[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   473
apply(case_tac q)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   474
apply(simp add: PosOrd_def pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   475
apply(clarify)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   476
apply(drule_tac x="Suc a # lista" in bspec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   477
apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   478
apply(auto simp add: PosOrd_def pflat_len_simps)[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   479
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   480
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   481
lemma PosOrd_Stars_appendE:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   482
  assumes "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   483
  shows "Stars vs1 :\<sqsubset>val Stars vs2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   484
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   485
apply(induct vs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   486
apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   487
apply(simp add: PosOrd_StarsE2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   488
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   489
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   490
lemma PosOrd_Stars_append_eq:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   491
  assumes "flats vs1 = flats vs2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   492
  shows "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2) \<longleftrightarrow> Stars vs1 :\<sqsubset>val Stars vs2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   493
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   494
apply(rule_tac iffI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   495
apply(erule PosOrd_Stars_appendE)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   496
apply(rule PosOrd_Stars_appendI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   497
apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   498
done  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   499
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   500
lemma PosOrd_almost_trichotomous:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   501
  shows "v1 :\<sqsubset>val v2 \<or> v2 :\<sqsubset>val v1 \<or> (length (flat v1) = length (flat v2))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   502
apply(auto simp add: PosOrd_ex_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   503
apply(auto simp add: PosOrd_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   504
apply(rule_tac x="[]" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   505
apply(auto simp add: Pos_empty pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   506
apply(drule_tac x="[]" in spec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   507
apply(auto simp add: Pos_empty pflat_len_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   508
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   509
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   510
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   511
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   512
section \<open>The Posix Value is smaller than any other Value\<close>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   513
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   514
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   515
lemma Posix_PosOrd:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   516
  assumes "s \<in> r \<rightarrow> v1" "v2 \<in> LV r s" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   517
  shows "v1 :\<sqsubseteq>val v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   518
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   519
proof (induct arbitrary: v2 rule: Posix.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   520
  case (Posix_ONE v)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   521
  have "v \<in> LV ONE []" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   522
  then have "v = Void"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   523
    by (simp add: LV_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   524
  then show "Void :\<sqsubseteq>val v"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   525
    by (simp add: PosOrd_ex_eq_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   526
next
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   527
  case (Posix_CH c v)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   528
  have "v \<in> LV (CH c) [c]" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   529
  then have "v = Char c"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   530
    by (simp add: LV_simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   531
  then show "Char c :\<sqsubseteq>val v"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   532
    by (simp add: PosOrd_ex_eq_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   533
next
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   534
  case (Posix_ALT1 s r1 v r2 v2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   535
  have as1: "s \<in> r1 \<rightarrow> v" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   536
  have IH: "\<And>v2. v2 \<in> LV r1 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   537
  have "v2 \<in> LV (ALT r1 r2) s" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   538
  then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   539
    by(auto simp add: LV_def prefix_list_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   540
  then consider
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   541
    (Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   542
  | (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   543
  by (auto elim: Prf.cases)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   544
  then show "Left v :\<sqsubseteq>val v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   545
  proof(cases)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   546
     case (Left v3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   547
     have "v3 \<in> LV r1 s" using Left(2,3) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   548
       by (auto simp add: LV_def prefix_list_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   549
     with IH have "v :\<sqsubseteq>val v3" by simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   550
     moreover
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   551
     have "flat v3 = flat v" using as1 Left(3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   552
       by (simp add: Posix1(2)) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   553
     ultimately have "Left v :\<sqsubseteq>val Left v3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   554
       by (simp add: PosOrd_ex_eq_def PosOrd_Left_eq)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   555
     then show "Left v :\<sqsubseteq>val v2" unfolding Left .
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   556
  next
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   557
     case (Right v3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   558
     have "flat v3 = flat v" using as1 Right(3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   559
       by (simp add: Posix1(2)) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   560
     then have "Left v :\<sqsubseteq>val Right v3" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   561
       unfolding PosOrd_ex_eq_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   562
       by (simp add: PosOrd_Left_Right)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   563
     then show "Left v :\<sqsubseteq>val v2" unfolding Right .
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   564
  qed
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   565
next
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   566
  case (Posix_ALT2 s r2 v r1 v2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   567
  have as1: "s \<in> r2 \<rightarrow> v" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   568
  have as2: "s \<notin> L r1" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   569
  have IH: "\<And>v2. v2 \<in> LV r2 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   570
  have "v2 \<in> LV (ALT r1 r2) s" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   571
  then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   572
    by(auto simp add: LV_def prefix_list_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   573
  then consider
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   574
    (Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   575
  | (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   576
  by (auto elim: Prf.cases)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   577
  then show "Right v :\<sqsubseteq>val v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   578
  proof (cases)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   579
    case (Right v3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   580
     have "v3 \<in> LV r2 s" using Right(2,3) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   581
       by (auto simp add: LV_def prefix_list_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   582
     with IH have "v :\<sqsubseteq>val v3" by simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   583
     moreover
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   584
     have "flat v3 = flat v" using as1 Right(3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   585
       by (simp add: Posix1(2)) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   586
     ultimately have "Right v :\<sqsubseteq>val Right v3" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   587
        by (auto simp add: PosOrd_ex_eq_def PosOrd_RightI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   588
     then show "Right v :\<sqsubseteq>val v2" unfolding Right .
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   589
  next
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   590
     case (Left v3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   591
     have "v3 \<in> LV r1 s" using Left(2,3) as2  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   592
       by (auto simp add: LV_def prefix_list_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   593
     then have "flat v3 = flat v \<and> \<Turnstile> v3 : r1" using as1 Left(3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   594
       by (simp add: Posix1(2) LV_def) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   595
     then have "False" using as1 as2 Left
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   596
       by (auto simp add: Posix1(2) L_flat_Prf1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   597
     then show "Right v :\<sqsubseteq>val v2" by simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   598
  qed
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   599
next 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   600
  case (Posix_SEQ s1 r1 v1 s2 r2 v2 v3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   601
  have "s1 \<in> r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" by fact+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   602
  then have as1: "s1 = flat v1" "s2 = flat v2" by (simp_all add: Posix1(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   603
  have IH1: "\<And>v3. v3 \<in> LV r1 s1 \<Longrightarrow> v1 :\<sqsubseteq>val v3" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   604
  have IH2: "\<And>v3. v3 \<in> LV r2 s2 \<Longrightarrow> v2 :\<sqsubseteq>val v3" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   605
  have cond: "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   606
  have "v3 \<in> LV (SEQ r1 r2) (s1 @ s2)" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   607
  then obtain v3a v3b where eqs:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   608
    "v3 = Seq v3a v3b" "\<Turnstile> v3a : r1" "\<Turnstile> v3b : r2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   609
    "flat v3a @ flat v3b = s1 @ s2" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   610
    by (force simp add: prefix_list_def LV_def elim: Prf.cases)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   611
  with cond have "flat v3a \<sqsubseteq>pre s1" unfolding prefix_list_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   612
    by (smt L_flat_Prf1 append_eq_append_conv2 append_self_conv)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   613
  then have "flat v3a \<sqsubset>spre s1 \<or> (flat v3a = s1 \<and> flat v3b = s2)" using eqs
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   614
    by (simp add: sprefix_list_def append_eq_conv_conj)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   615
  then have q2: "v1 :\<sqsubset>val v3a \<or> (flat v3a = s1 \<and> flat v3b = s2)" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   616
    using PosOrd_spreI as1(1) eqs by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   617
  then have "v1 :\<sqsubset>val v3a \<or> (v3a \<in> LV r1 s1 \<and> v3b \<in> LV r2 s2)" using eqs(2,3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   618
    by (auto simp add: LV_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   619
  then have "v1 :\<sqsubset>val v3a \<or> (v1 :\<sqsubseteq>val v3a \<and> v2 :\<sqsubseteq>val v3b)" using IH1 IH2 by blast         
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   620
  then have "Seq v1 v2 :\<sqsubseteq>val Seq v3a v3b" using eqs q2 as1
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   621
    unfolding  PosOrd_ex_eq_def by (auto simp add: PosOrd_SeqI1 PosOrd_Seq_eq) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   622
  then show "Seq v1 v2 :\<sqsubseteq>val v3" unfolding eqs by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   623
next 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   624
  case (Posix_STAR1 s1 r v s2 vs v3) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   625
  have "s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" by fact+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   626
  then have as1: "s1 = flat v" "s2 = flat (Stars vs)" by (auto dest: Posix1(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   627
  have IH1: "\<And>v3. v3 \<in> LV r s1 \<Longrightarrow> v :\<sqsubseteq>val v3" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   628
  have IH2: "\<And>v3. v3 \<in> LV (STAR r) s2 \<Longrightarrow> Stars vs :\<sqsubseteq>val v3" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   629
  have cond: "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   630
  have cond2: "flat v \<noteq> []" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   631
  have "v3 \<in> LV (STAR r) (s1 @ s2)" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   632
  then consider 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   633
    (NonEmpty) v3a vs3 where "v3 = Stars (v3a # vs3)" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   634
    "\<Turnstile> v3a : r" "\<Turnstile> Stars vs3 : STAR r"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   635
    "flat (Stars (v3a # vs3)) = s1 @ s2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   636
  | (Empty) "v3 = Stars []"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   637
  unfolding LV_def  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   638
  apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   639
  apply(erule Prf.cases)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   640
  apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   641
  apply(case_tac vs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   642
  apply(auto intro: Prf.intros)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   643
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   644
  then show "Stars (v # vs) :\<sqsubseteq>val v3" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   645
    proof (cases)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   646
      case (NonEmpty v3a vs3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   647
      have "flat (Stars (v3a # vs3)) = s1 @ s2" using NonEmpty(4) . 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   648
      with cond have "flat v3a \<sqsubseteq>pre s1" using NonEmpty(2,3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   649
        unfolding prefix_list_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   650
        by (smt L_flat_Prf1 append_Nil2 append_eq_append_conv2 flat.simps(7)) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   651
      then have "flat v3a \<sqsubset>spre s1 \<or> (flat v3a = s1 \<and> flat (Stars vs3) = s2)" using NonEmpty(4)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   652
        by (simp add: sprefix_list_def append_eq_conv_conj)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   653
      then have q2: "v :\<sqsubset>val v3a \<or> (flat v3a = s1 \<and> flat (Stars vs3) = s2)" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   654
        using PosOrd_spreI as1(1) NonEmpty(4) by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   655
      then have "v :\<sqsubset>val v3a \<or> (v3a \<in> LV r s1 \<and> Stars vs3 \<in> LV (STAR r) s2)" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   656
        using NonEmpty(2,3) by (auto simp add: LV_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   657
      then have "v :\<sqsubset>val v3a \<or> (v :\<sqsubseteq>val v3a \<and> Stars vs :\<sqsubseteq>val Stars vs3)" using IH1 IH2 by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   658
      then have "v :\<sqsubset>val v3a \<or> (v = v3a \<and> Stars vs :\<sqsubseteq>val Stars vs3)" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   659
         unfolding PosOrd_ex_eq_def by auto     
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   660
      then have "Stars (v # vs) :\<sqsubseteq>val Stars (v3a # vs3)" using NonEmpty(4) q2 as1
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   661
        unfolding  PosOrd_ex_eq_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   662
        using PosOrd_StarsI PosOrd_StarsI2 by auto 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   663
      then show "Stars (v # vs) :\<sqsubseteq>val v3" unfolding NonEmpty by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   664
    next 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   665
      case Empty
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   666
      have "v3 = Stars []" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   667
      then show "Stars (v # vs) :\<sqsubseteq>val v3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   668
      unfolding PosOrd_ex_eq_def using cond2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   669
      by (simp add: PosOrd_shorterI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   670
    qed      
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   671
next 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   672
  case (Posix_STAR2 r v2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   673
  have "v2 \<in> LV (STAR r) []" by fact
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   674
  then have "v2 = Stars []" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   675
    unfolding LV_def by (auto elim: Prf.cases) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   676
  then show "Stars [] :\<sqsubseteq>val v2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   677
  by (simp add: PosOrd_ex_eq_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   678
qed
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   679
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   680
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   681
lemma Posix_PosOrd_reverse:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   682
  assumes "s \<in> r \<rightarrow> v1" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   683
  shows "\<not>(\<exists>v2 \<in> LV r s. v2 :\<sqsubset>val v1)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   684
using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   685
by (metis Posix_PosOrd less_irrefl PosOrd_def 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   686
    PosOrd_ex_eq_def PosOrd_ex_def PosOrd_trans)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   687
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   688
lemma PosOrd_Posix:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   689
  assumes "v1 \<in> LV r s" "\<forall>v\<^sub>2 \<in> LV r s. \<not> v\<^sub>2 :\<sqsubset>val v1"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   690
  shows "s \<in> r \<rightarrow> v1" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   691
proof -
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   692
  have "s \<in> L r" using assms(1) unfolding LV_def
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   693
    using L_flat_Prf1 by blast 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   694
  then obtain vposix where vp: "s \<in> r \<rightarrow> vposix"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   695
    using lexer_correct_Some by blast 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   696
  with assms(1) have "vposix :\<sqsubseteq>val v1" by (simp add: Posix_PosOrd) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   697
  then have "vposix = v1 \<or> vposix :\<sqsubset>val v1" unfolding PosOrd_ex_eq2 by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   698
  moreover
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   699
    { assume "vposix :\<sqsubset>val v1"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   700
      moreover
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   701
      have "vposix \<in> LV r s" using vp 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   702
         using Posix_LV by blast 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   703
      ultimately have "False" using assms(2) by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   704
    }
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   705
  ultimately show "s \<in> r \<rightarrow> v1" using vp by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   706
qed
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   707
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   708
lemma Least_existence:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   709
  assumes "LV r s \<noteq> {}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   710
  shows " \<exists>vmin \<in> LV r s. \<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   711
proof -
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   712
  from assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   713
  obtain vposix where "s \<in> r \<rightarrow> vposix"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   714
  unfolding LV_def 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   715
  using L_flat_Prf1 lexer_correct_Some by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   716
  then have "\<forall>v \<in> LV r s. vposix :\<sqsubseteq>val v"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   717
    by (simp add: Posix_PosOrd)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   718
  then show "\<exists>vmin \<in> LV r s. \<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   719
    using Posix_LV \<open>s \<in> r \<rightarrow> vposix\<close> by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   720
qed 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   721
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   722
lemma Least_existence1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   723
  assumes "LV r s \<noteq> {}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   724
  shows " \<exists>!vmin \<in> LV r s. \<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   725
using Least_existence[OF assms] assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   726
using PosOrdeq_antisym by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   727
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   728
lemma Least_existence2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   729
  assumes "LV r s \<noteq> {}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   730
  shows " \<exists>!vmin \<in> LV r s. lexer r s = Some vmin \<and> (\<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   731
using Least_existence[OF assms] assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   732
using PosOrdeq_antisym 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   733
  using PosOrd_Posix PosOrd_ex_eq2 lexer_correctness(1) by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   734
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   735
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   736
lemma Least_existence1_pre:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   737
  assumes "LV r s \<noteq> {}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   738
  shows " \<exists>!vmin \<in> LV r s. \<forall>v \<in> (LV r s \<union> {v'. flat v' \<sqsubset>spre s}). vmin :\<sqsubseteq>val v"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   739
using Least_existence[OF assms] assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   740
apply -
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   741
apply(erule bexE)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   742
apply(rule_tac a="vmin" in ex1I)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   743
apply(auto)[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   744
apply (metis PosOrd_Posix PosOrd_ex_eq2 PosOrd_spreI PosOrdeq_antisym Posix1(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   745
apply(auto)[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   746
apply(simp add: PosOrdeq_antisym)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   747
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   748
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   749
lemma
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   750
  shows "partial_order_on UNIV {(v1, v2). v1 :\<sqsubseteq>val v2}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   751
apply(simp add: partial_order_on_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   752
apply(simp add: preorder_on_def refl_on_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   753
apply(simp add: PosOrdeq_refl)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   754
apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   755
apply(rule transI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   756
apply(auto intro: PosOrdeq_trans)[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   757
apply(rule antisymI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   758
apply(simp add: PosOrdeq_antisym)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   759
done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   760
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   761
lemma
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   762
 "wf {(v1, v2). v1 :\<sqsubset>val v2 \<and> v1 \<in> LV r s \<and> v2 \<in> LV r s}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   763
apply(rule finite_acyclic_wf)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   764
prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   765
apply(simp add: acyclic_def)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   766
apply(induct_tac rule: trancl.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   767
apply(auto)[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   768
oops
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   769
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   770
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   771
unused_thms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   772
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   773
end