src/HOL/Hoare_Parallel/OG_Com.thy
author haftmann
Mon Sep 21 10:58:25 2009 +0200 (2009-09-21)
changeset 32621 a073cb249a06
parent 16417 src/HOL/HoareParallel/OG_Com.thy@9bc16273c2d4
child 39246 9e58f0499f57
permissions -rw-r--r--
theory entry point for session Hoare_Parallel (now also with proper underscore)
prensani@13020
     1
prensani@13020
     2
header {* \chapter{The Owicki-Gries Method} 
prensani@13020
     3
prensani@13020
     4
\section{Abstract Syntax} *} 
prensani@13020
     5
haftmann@16417
     6
theory OG_Com imports Main begin
prensani@13020
     7
prensani@13020
     8
text {* Type abbreviations for boolean expressions and assertions: *}
prensani@13020
     9
prensani@13020
    10
types
prensani@13020
    11
    'a bexp = "'a set"
prensani@13020
    12
    'a assn = "'a set"
prensani@13020
    13
prensani@13020
    14
text {* The syntax of commands is defined by two mutually recursive
prensani@13020
    15
datatypes: @{text "'a ann_com"} for annotated commands and @{text "'a
prensani@13020
    16
com"} for non-annotated commands. *}
prensani@13020
    17
prensani@13020
    18
datatype 'a ann_com = 
prensani@13020
    19
     AnnBasic "('a assn)"  "('a \<Rightarrow> 'a)"         
prensani@13020
    20
   | AnnSeq "('a ann_com)"  "('a ann_com)"   
prensani@13020
    21
   | AnnCond1 "('a assn)"  "('a bexp)"  "('a ann_com)"  "('a ann_com)" 
prensani@13020
    22
   | AnnCond2 "('a assn)"  "('a bexp)"  "('a ann_com)" 
prensani@13020
    23
   | AnnWhile "('a assn)"  "('a bexp)"  "('a assn)"  "('a ann_com)" 
prensani@13020
    24
   | AnnAwait "('a assn)"  "('a bexp)"  "('a com)" 
prensani@13020
    25
and 'a com = 
prensani@13020
    26
     Parallel "('a ann_com option \<times> 'a assn) list"
prensani@13020
    27
   | Basic "('a \<Rightarrow> 'a)" 
prensani@13020
    28
   | Seq "('a com)"  "('a com)" 
prensani@13020
    29
   | Cond "('a bexp)"  "('a com)"  "('a com)" 
prensani@13020
    30
   | While "('a bexp)"  "('a assn)"  "('a com)"
prensani@13020
    31
prensani@13020
    32
text {* The function @{text pre} extracts the precondition of an
prensani@13020
    33
annotated command: *}
prensani@13020
    34
prensani@13020
    35
consts
prensani@13020
    36
  pre ::"'a ann_com \<Rightarrow> 'a assn" 
prensani@13020
    37
primrec 
prensani@13020
    38
  "pre (AnnBasic r f) = r"
prensani@13020
    39
  "pre (AnnSeq c1 c2) = pre c1"
prensani@13020
    40
  "pre (AnnCond1 r b c1 c2) = r"
prensani@13020
    41
  "pre (AnnCond2 r b c) = r"
prensani@13020
    42
  "pre (AnnWhile r b i c) = r"
prensani@13020
    43
  "pre (AnnAwait r b c) = r"
prensani@13020
    44
prensani@13020
    45
text {* Well-formedness predicate for atomic programs: *}
prensani@13020
    46
prensani@13020
    47
consts atom_com :: "'a com \<Rightarrow> bool"
prensani@13020
    48
primrec  
prensani@13020
    49
  "atom_com (Parallel Ts) = False"
prensani@13020
    50
  "atom_com (Basic f) = True"
prensani@13020
    51
  "atom_com (Seq c1 c2) = (atom_com c1 \<and> atom_com c2)"
prensani@13020
    52
  "atom_com (Cond b c1 c2) = (atom_com c1 \<and> atom_com c2)"
prensani@13020
    53
  "atom_com (While b i c) = atom_com c"
prensani@13020
    54
  
prensani@13020
    55
end