src/HOL/Hoare_Parallel/OG_Tran.thy
author blanchet
Tue, 12 Nov 2013 13:47:24 +0100
changeset 54396 8baee6b04a7c
parent 52141 eff000cab70f
child 58884 be4d203d35b3
permissions -rw-r--r--
moved 'Ctr_Sugar' files out of BNF, so that it can become a general-purpose abstraction
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     1
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     2
header {* \section{Operational Semantics} *}
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     3
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 13020
diff changeset
     4
theory OG_Tran imports OG_Com begin
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     5
42174
d0be2722ce9f modernized specifications;
wenzelm
parents: 35416
diff changeset
     6
type_synonym 'a ann_com_op = "('a ann_com) option"
d0be2722ce9f modernized specifications;
wenzelm
parents: 35416
diff changeset
     7
type_synonym 'a ann_triple_op = "('a ann_com_op \<times> 'a assn)"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     8
  
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
     9
primrec com :: "'a ann_triple_op \<Rightarrow> 'a ann_com_op" where
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
    10
  "com (c, q) = c"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    11
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
    12
primrec post :: "'a ann_triple_op \<Rightarrow> 'a assn" where
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
    13
  "post (c, q) = q"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    14
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
    15
definition All_None :: "'a ann_triple_op list \<Rightarrow> bool" where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    16
  "All_None Ts \<equiv> \<forall>(c, q) \<in> set Ts. c = None"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    17
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    18
subsection {* The Transition Relation *}
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    19
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    20
inductive_set
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    21
  ann_transition :: "(('a ann_com_op \<times> 'a) \<times> ('a ann_com_op \<times> 'a)) set"        
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    22
  and transition :: "(('a com \<times> 'a) \<times> ('a com \<times> 'a)) set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    23
  and ann_transition' :: "('a ann_com_op \<times> 'a) \<Rightarrow> ('a ann_com_op \<times> 'a) \<Rightarrow> bool"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    24
    ("_ -1\<rightarrow> _"[81,81] 100)
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    25
  and transition' :: "('a com \<times> 'a) \<Rightarrow> ('a com \<times> 'a) \<Rightarrow> bool"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    26
    ("_ -P1\<rightarrow> _"[81,81] 100)
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    27
  and transitions :: "('a com \<times> 'a) \<Rightarrow> ('a com \<times> 'a) \<Rightarrow> bool"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    28
    ("_ -P*\<rightarrow> _"[81,81] 100)
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    29
where
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    30
  "con_0 -1\<rightarrow> con_1 \<equiv> (con_0, con_1) \<in> ann_transition"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    31
| "con_0 -P1\<rightarrow> con_1 \<equiv> (con_0, con_1) \<in> transition"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    32
| "con_0 -P*\<rightarrow> con_1 \<equiv> (con_0, con_1) \<in> transition\<^sup>*"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    33
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    34
| AnnBasic:  "(Some (AnnBasic r f), s) -1\<rightarrow> (None, f s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    35
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    36
| AnnSeq1: "(Some c0, s) -1\<rightarrow> (None, t) \<Longrightarrow> 
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    37
               (Some (AnnSeq c0 c1), s) -1\<rightarrow> (Some c1, t)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    38
| AnnSeq2: "(Some c0, s) -1\<rightarrow> (Some c2, t) \<Longrightarrow> 
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    39
               (Some (AnnSeq c0 c1), s) -1\<rightarrow> (Some (AnnSeq c2 c1), t)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    40
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    41
| AnnCond1T: "s \<in> b  \<Longrightarrow> (Some (AnnCond1 r b c1 c2), s) -1\<rightarrow> (Some c1, s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    42
| AnnCond1F: "s \<notin> b \<Longrightarrow> (Some (AnnCond1 r b c1 c2), s) -1\<rightarrow> (Some c2, s)"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    43
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    44
| AnnCond2T: "s \<in> b  \<Longrightarrow> (Some (AnnCond2 r b c), s) -1\<rightarrow> (Some c, s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    45
| AnnCond2F: "s \<notin> b \<Longrightarrow> (Some (AnnCond2 r b c), s) -1\<rightarrow> (None, s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    46
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    47
| AnnWhileF: "s \<notin> b \<Longrightarrow> (Some (AnnWhile r b i c), s) -1\<rightarrow> (None, s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    48
| AnnWhileT: "s \<in> b  \<Longrightarrow> (Some (AnnWhile r b i c), s) -1\<rightarrow> 
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    49
                         (Some (AnnSeq c (AnnWhile i b i c)), s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    50
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    51
| AnnAwait: "\<lbrakk> s \<in> b; atom_com c; (c, s) -P*\<rightarrow> (Parallel [], t) \<rbrakk> \<Longrightarrow>
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32621
diff changeset
    52
                   (Some (AnnAwait r b c), s) -1\<rightarrow> (None, t)" 
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    53
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    54
| Parallel: "\<lbrakk> i<length Ts; Ts!i = (Some c, q); (Some c, s) -1\<rightarrow> (r, t) \<rbrakk>
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    55
              \<Longrightarrow> (Parallel Ts, s) -P1\<rightarrow> (Parallel (Ts [i:=(r, q)]), t)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    56
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    57
| Basic:  "(Basic f, s) -P1\<rightarrow> (Parallel [], f s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    58
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    59
| Seq1:   "All_None Ts \<Longrightarrow> (Seq (Parallel Ts) c, s) -P1\<rightarrow> (c, s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    60
| Seq2:   "(c0, s) -P1\<rightarrow> (c2, t) \<Longrightarrow> (Seq c0 c1, s) -P1\<rightarrow> (Seq c2 c1, t)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    61
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    62
| CondT: "s \<in> b \<Longrightarrow> (Cond b c1 c2, s) -P1\<rightarrow> (c1, s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    63
| CondF: "s \<notin> b \<Longrightarrow> (Cond b c1 c2, s) -P1\<rightarrow> (c2, s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    64
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    65
| WhileF: "s \<notin> b \<Longrightarrow> (While b i c, s) -P1\<rightarrow> (Parallel [], s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    66
| WhileT: "s \<in> b \<Longrightarrow> (While b i c, s) -P1\<rightarrow> (Seq c (While b i c), s)"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    67
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    68
monos "rtrancl_mono"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    69
35107
bdca9f765ee4 modernized translations;
wenzelm
parents: 32960
diff changeset
    70
text {* The corresponding abbreviations are: *}
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    71
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    72
abbreviation
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    73
  ann_transition_n :: "('a ann_com_op \<times> 'a) \<Rightarrow> nat \<Rightarrow> ('a ann_com_op \<times> 'a) 
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    74
                           \<Rightarrow> bool"  ("_ -_\<rightarrow> _"[81,81] 100)  where
30952
7ab2716dd93b power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents: 30304
diff changeset
    75
  "con_0 -n\<rightarrow> con_1 \<equiv> (con_0, con_1) \<in> ann_transition ^^ n"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    76
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    77
abbreviation
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    78
  ann_transitions :: "('a ann_com_op \<times> 'a) \<Rightarrow> ('a ann_com_op \<times> 'a) \<Rightarrow> bool"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    79
                           ("_ -*\<rightarrow> _"[81,81] 100)  where
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    80
  "con_0 -*\<rightarrow> con_1 \<equiv> (con_0, con_1) \<in> ann_transition\<^sup>*"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    81
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    82
abbreviation
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    83
  transition_n :: "('a com \<times> 'a) \<Rightarrow> nat \<Rightarrow> ('a com \<times> 'a) \<Rightarrow> bool"  
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    84
                          ("_ -P_\<rightarrow> _"[81,81,81] 100)  where
30952
7ab2716dd93b power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents: 30304
diff changeset
    85
  "con_0 -Pn\<rightarrow> con_1 \<equiv> (con_0, con_1) \<in> transition ^^ n"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    86
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    87
subsection {* Definition of Semantics *}
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    88
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
    89
definition ann_sem :: "'a ann_com \<Rightarrow> 'a \<Rightarrow> 'a set" where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    90
  "ann_sem c \<equiv> \<lambda>s. {t. (Some c, s) -*\<rightarrow> (None, t)}"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    91
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
    92
definition ann_SEM :: "'a ann_com \<Rightarrow> 'a set \<Rightarrow> 'a set" where
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 46362
diff changeset
    93
  "ann_SEM c S \<equiv> \<Union>(ann_sem c ` S)"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    94
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
    95
definition sem :: "'a com \<Rightarrow> 'a \<Rightarrow> 'a set" where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    96
  "sem c \<equiv> \<lambda>s. {t. \<exists>Ts. (c, s) -P*\<rightarrow> (Parallel Ts, t) \<and> All_None Ts}"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    97
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
    98
definition SEM :: "'a com \<Rightarrow> 'a set \<Rightarrow> 'a set" where
52141
eff000cab70f weaker precendence of syntax for big intersection and union on sets
haftmann
parents: 46362
diff changeset
    99
  "SEM c S \<equiv> \<Union>(sem c ` S)"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   100
35107
bdca9f765ee4 modernized translations;
wenzelm
parents: 32960
diff changeset
   101
abbreviation Omega :: "'a com"    ("\<Omega>" 63)
bdca9f765ee4 modernized translations;
wenzelm
parents: 32960
diff changeset
   102
  where "\<Omega> \<equiv> While UNIV UNIV (Basic id)"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   103
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
   104
primrec fwhile :: "'a bexp \<Rightarrow> 'a com \<Rightarrow> nat \<Rightarrow> 'a com" where
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
   105
    "fwhile b c 0 = \<Omega>"
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
   106
  | "fwhile b c (Suc n) = Cond b (Seq c (fwhile b c n)) (Basic id)"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   107
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   108
subsubsection {* Proofs *}
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   109
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   110
declare ann_transition_transition.intros [intro]
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   111
inductive_cases transition_cases: 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   112
    "(Parallel T,s) -P1\<rightarrow> t"  
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   113
    "(Basic f, s) -P1\<rightarrow> t"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   114
    "(Seq c1 c2, s) -P1\<rightarrow> t" 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   115
    "(Cond b c1 c2, s) -P1\<rightarrow> t"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   116
    "(While b i c, s) -P1\<rightarrow> t"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   117
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   118
lemma Parallel_empty_lemma [rule_format (no_asm)]: 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   119
  "(Parallel [],s) -Pn\<rightarrow> (Parallel Ts,t) \<longrightarrow> Ts=[] \<and> n=0 \<and> s=t"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   120
apply(induct n)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   121
 apply(simp (no_asm))
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   122
apply clarify
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   123
apply(drule relpow_Suc_D2)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   124
apply(force elim:transition_cases)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   125
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   126
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   127
lemma Parallel_AllNone_lemma [rule_format (no_asm)]: 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   128
 "All_None Ss \<longrightarrow> (Parallel Ss,s) -Pn\<rightarrow> (Parallel Ts,t) \<longrightarrow> Ts=Ss \<and> n=0 \<and> s=t"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   129
apply(induct "n")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   130
 apply(simp (no_asm))
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   131
apply clarify
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   132
apply(drule relpow_Suc_D2)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   133
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   134
apply(erule transition_cases,simp_all)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   135
apply(force dest:nth_mem simp add:All_None_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   136
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   137
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   138
lemma Parallel_AllNone: "All_None Ts \<Longrightarrow> (SEM (Parallel Ts) X) = X"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   139
apply (unfold SEM_def sem_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   140
apply auto
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   141
apply(drule rtrancl_imp_UN_relpow)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   142
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   143
apply(drule Parallel_AllNone_lemma)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   144
apply auto
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   145
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   146
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   147
lemma Parallel_empty: "Ts=[] \<Longrightarrow> (SEM (Parallel Ts) X) = X"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   148
apply(rule Parallel_AllNone)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   149
apply(simp add:All_None_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   150
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   151
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   152
text {* Set of lemmas from Apt and Olderog "Verification of sequential
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   153
and concurrent programs", page 63. *}
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   154
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   155
lemma L3_5i: "X\<subseteq>Y \<Longrightarrow> SEM c X \<subseteq> SEM c Y" 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   156
apply (unfold SEM_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   157
apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   158
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   159
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   160
lemma L3_5ii_lemma1: 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   161
 "\<lbrakk> (c1, s1) -P*\<rightarrow> (Parallel Ts, s2); All_None Ts;  
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   162
  (c2, s2) -P*\<rightarrow> (Parallel Ss, s3); All_None Ss \<rbrakk> 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   163
 \<Longrightarrow> (Seq c1 c2, s1) -P*\<rightarrow> (Parallel Ss, s3)"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   164
apply(erule converse_rtrancl_induct2)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   165
apply(force intro:converse_rtrancl_into_rtrancl)+
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   166
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   167
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   168
lemma L3_5ii_lemma2 [rule_format (no_asm)]: 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   169
 "\<forall>c1 c2 s t. (Seq c1 c2, s) -Pn\<rightarrow> (Parallel Ts, t) \<longrightarrow>  
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   170
  (All_None Ts) \<longrightarrow> (\<exists>y m Rs. (c1,s) -P*\<rightarrow> (Parallel Rs, y) \<and> 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   171
  (All_None Rs) \<and> (c2, y) -Pm\<rightarrow> (Parallel Ts, t) \<and>  m \<le> n)"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   172
apply(induct "n")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   173
 apply(force)
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   174
apply(safe dest!: relpow_Suc_D2)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   175
apply(erule transition_cases,simp_all)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   176
 apply (fast intro!: le_SucI)
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   177
apply (fast intro!: le_SucI elim!: relpow_imp_rtrancl converse_rtrancl_into_rtrancl)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   178
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   179
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   180
lemma L3_5ii_lemma3: 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   181
 "\<lbrakk>(Seq c1 c2,s) -P*\<rightarrow> (Parallel Ts,t); All_None Ts\<rbrakk> \<Longrightarrow> 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   182
    (\<exists>y Rs. (c1,s) -P*\<rightarrow> (Parallel Rs,y) \<and> All_None Rs 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   183
   \<and> (c2,y) -P*\<rightarrow> (Parallel Ts,t))"
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   184
apply(drule rtrancl_imp_UN_relpow)
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   185
apply(fast dest: L3_5ii_lemma2 relpow_imp_rtrancl)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   186
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   187
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   188
lemma L3_5ii: "SEM (Seq c1 c2) X = SEM c2 (SEM c1 X)"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   189
apply (unfold SEM_def sem_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   190
apply auto
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   191
 apply(fast dest: L3_5ii_lemma3)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   192
apply(fast elim: L3_5ii_lemma1)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   193
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   194
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   195
lemma L3_5iii: "SEM (Seq (Seq c1 c2) c3) X = SEM (Seq c1 (Seq c2 c3)) X"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   196
apply (simp (no_asm) add: L3_5ii)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   197
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   198
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   199
lemma L3_5iv:
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   200
 "SEM (Cond b c1 c2) X = (SEM c1 (X \<inter> b)) Un (SEM c2 (X \<inter> (-b)))"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   201
apply (unfold SEM_def sem_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   202
apply auto
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   203
apply(erule converse_rtranclE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   204
 prefer 2
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   205
 apply (erule transition_cases,simp_all)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   206
  apply(fast intro: converse_rtrancl_into_rtrancl elim: transition_cases)+
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   207
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   208
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   209
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   210
lemma  L3_5v_lemma1[rule_format]: 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   211
 "(S,s) -Pn\<rightarrow> (T,t) \<longrightarrow> S=\<Omega> \<longrightarrow> (\<not>(\<exists>Rs. T=(Parallel Rs) \<and> All_None Rs))"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   212
apply (unfold UNIV_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   213
apply(rule nat_less_induct)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   214
apply safe
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   215
apply(erule relpow_E2)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   216
 apply simp_all
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   217
apply(erule transition_cases)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   218
 apply simp_all
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   219
apply(erule relpow_E2)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   220
 apply(simp add: Id_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   221
apply(erule transition_cases,simp_all)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   222
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   223
apply(erule transition_cases,simp_all)
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   224
apply(erule relpow_E2,simp)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   225
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   226
apply(erule transition_cases)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   227
 apply simp+
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   228
    apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   229
    apply(erule transition_cases)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   230
apply simp_all
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   231
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   232
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   233
lemma L3_5v_lemma2: "\<lbrakk>(\<Omega>, s) -P*\<rightarrow> (Parallel Ts, t); All_None Ts \<rbrakk> \<Longrightarrow> False"
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   234
apply(fast dest: rtrancl_imp_UN_relpow L3_5v_lemma1)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   235
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   236
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   237
lemma L3_5v_lemma3: "SEM (\<Omega>) S = {}"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   238
apply (unfold SEM_def sem_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   239
apply(fast dest: L3_5v_lemma2)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   240
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   241
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   242
lemma L3_5v_lemma4 [rule_format]: 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   243
 "\<forall>s. (While b i c, s) -Pn\<rightarrow> (Parallel Ts, t) \<longrightarrow> All_None Ts \<longrightarrow>  
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   244
  (\<exists>k. (fwhile b c k, s) -P*\<rightarrow> (Parallel Ts, t))"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   245
apply(rule nat_less_induct)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   246
apply safe
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   247
apply(erule relpow_E2)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   248
 apply safe
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   249
apply(erule transition_cases,simp_all)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   250
 apply (rule_tac x = "1" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   251
 apply(force dest: Parallel_empty_lemma intro: converse_rtrancl_into_rtrancl simp add: Id_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   252
apply safe
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   253
apply(drule L3_5ii_lemma2)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   254
 apply safe
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   255
apply(drule le_imp_less_Suc)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   256
apply (erule allE , erule impE,assumption)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   257
apply (erule allE , erule impE, assumption)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   258
apply safe
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   259
apply (rule_tac x = "k+1" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   260
apply(simp (no_asm))
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   261
apply(rule converse_rtrancl_into_rtrancl)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   262
 apply fast
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   263
apply(fast elim: L3_5ii_lemma1)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   264
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   265
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   266
lemma L3_5v_lemma5 [rule_format]: 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   267
 "\<forall>s. (fwhile b c k, s) -P*\<rightarrow> (Parallel Ts, t) \<longrightarrow> All_None Ts \<longrightarrow>  
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   268
  (While b i c, s) -P*\<rightarrow> (Parallel Ts,t)"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   269
apply(induct "k")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   270
 apply(force dest: L3_5v_lemma2)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   271
apply safe
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   272
apply(erule converse_rtranclE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   273
 apply simp_all
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   274
apply(erule transition_cases,simp_all)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   275
 apply(rule converse_rtrancl_into_rtrancl)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   276
  apply(fast)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   277
 apply(fast elim!: L3_5ii_lemma1 dest: L3_5ii_lemma3)
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   278
apply(drule rtrancl_imp_UN_relpow)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   279
apply clarify
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   280
apply(erule relpow_E2)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   281
 apply simp_all
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   282
apply(erule transition_cases,simp_all)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   283
apply(fast dest: Parallel_empty_lemma)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   284
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   285
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   286
lemma L3_5v: "SEM (While b i c) = (\<lambda>x. (\<Union>k. SEM (fwhile b c k) x))"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   287
apply(rule ext)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   288
apply (simp add: SEM_def sem_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   289
apply safe
46362
b2878f059f91 renaming all lemmas with name rel_pow to relpow
bulwahn
parents: 42174
diff changeset
   290
 apply(drule rtrancl_imp_UN_relpow,simp)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   291
 apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   292
 apply(fast dest:L3_5v_lemma4)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   293
apply(fast intro: L3_5v_lemma5)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   294
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   295
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   296
section {* Validity of Correctness Formulas *}
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   297
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
   298
definition com_validity :: "'a assn \<Rightarrow> 'a com \<Rightarrow> 'a assn \<Rightarrow> bool" ("(3\<parallel>= _// _//_)" [90,55,90] 50) where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   299
  "\<parallel>= p c q \<equiv> SEM c p \<subseteq> q"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   300
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 35107
diff changeset
   301
definition ann_com_validity :: "'a ann_com \<Rightarrow> 'a assn \<Rightarrow> bool" ("\<Turnstile> _ _" [60,90] 45) where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   302
  "\<Turnstile> c q \<equiv> ann_SEM c (pre c) \<subseteq> q"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   303
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   304
end