src/HOL/Hoare_Parallel/OG_Com.thy
author wenzelm
Sat, 07 Apr 2012 16:41:59 +0200
changeset 47389 e8552cba702d
parent 42174 d0be2722ce9f
child 58249 180f1b3508ed
permissions -rw-r--r--
explicit checks stable_finished_theory/stable_command allow parallel asynchronous command transactions; tuned;
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 {* \chapter{The Owicki-Gries Method} 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     3
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     4
\section{Abstract Syntax} *} 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     5
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 13020
diff changeset
     6
theory OG_Com imports Main begin
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     7
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     8
text {* Type abbreviations for boolean expressions and assertions: *}
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     9
42174
d0be2722ce9f modernized specifications;
wenzelm
parents: 39246
diff changeset
    10
type_synonym 'a bexp = "'a set"
d0be2722ce9f modernized specifications;
wenzelm
parents: 39246
diff changeset
    11
type_synonym 'a assn = "'a set"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    12
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    13
text {* The syntax of commands is defined by two mutually recursive
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    14
datatypes: @{text "'a ann_com"} for annotated commands and @{text "'a
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    15
com"} for non-annotated commands. *}
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    16
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    17
datatype 'a ann_com = 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    18
     AnnBasic "('a assn)"  "('a \<Rightarrow> 'a)"         
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    19
   | AnnSeq "('a ann_com)"  "('a ann_com)"   
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    20
   | AnnCond1 "('a assn)"  "('a bexp)"  "('a ann_com)"  "('a ann_com)" 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    21
   | AnnCond2 "('a assn)"  "('a bexp)"  "('a ann_com)" 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    22
   | AnnWhile "('a assn)"  "('a bexp)"  "('a assn)"  "('a ann_com)" 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    23
   | AnnAwait "('a assn)"  "('a bexp)"  "('a com)" 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    24
and 'a com = 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    25
     Parallel "('a ann_com option \<times> 'a assn) list"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    26
   | Basic "('a \<Rightarrow> 'a)" 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    27
   | Seq "('a com)"  "('a com)" 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    28
   | Cond "('a bexp)"  "('a com)"  "('a com)" 
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    29
   | While "('a bexp)"  "('a assn)"  "('a com)"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    30
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    31
text {* The function @{text pre} extracts the precondition of an
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    32
annotated command: *}
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    33
39246
9e58f0499f57 modernized primrec
haftmann
parents: 32621
diff changeset
    34
primrec pre ::"'a ann_com \<Rightarrow> 'a assn"  where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    35
  "pre (AnnBasic r f) = r"
39246
9e58f0499f57 modernized primrec
haftmann
parents: 32621
diff changeset
    36
| "pre (AnnSeq c1 c2) = pre c1"
9e58f0499f57 modernized primrec
haftmann
parents: 32621
diff changeset
    37
| "pre (AnnCond1 r b c1 c2) = r"
9e58f0499f57 modernized primrec
haftmann
parents: 32621
diff changeset
    38
| "pre (AnnCond2 r b c) = r"
9e58f0499f57 modernized primrec
haftmann
parents: 32621
diff changeset
    39
| "pre (AnnWhile r b i c) = r"
9e58f0499f57 modernized primrec
haftmann
parents: 32621
diff changeset
    40
| "pre (AnnAwait r b c) = r"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    41
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    42
text {* Well-formedness predicate for atomic programs: *}
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    43
39246
9e58f0499f57 modernized primrec
haftmann
parents: 32621
diff changeset
    44
primrec atom_com :: "'a com \<Rightarrow> bool" where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    45
  "atom_com (Parallel Ts) = False"
39246
9e58f0499f57 modernized primrec
haftmann
parents: 32621
diff changeset
    46
| "atom_com (Basic f) = True"
9e58f0499f57 modernized primrec
haftmann
parents: 32621
diff changeset
    47
| "atom_com (Seq c1 c2) = (atom_com c1 \<and> atom_com c2)"
9e58f0499f57 modernized primrec
haftmann
parents: 32621
diff changeset
    48
| "atom_com (Cond b c1 c2) = (atom_com c1 \<and> atom_com c2)"
9e58f0499f57 modernized primrec
haftmann
parents: 32621
diff changeset
    49
| "atom_com (While b i c) = atom_com c"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    50
  
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    51
end