modernized translations;
authorwenzelm
Thu Feb 11 13:54:53 2010 +0100 (2010-02-11)
changeset 35107bdca9f765ee4
parent 35106 a0334d7fb0ab
child 35108 e384e27c229f
modernized translations;
src/HOL/Hoare_Parallel/OG_Syntax.thy
src/HOL/Hoare_Parallel/OG_Tran.thy
src/HOL/Hoare_Parallel/Quote_Antiquote.thy
src/HOL/Hoare_Parallel/RG_Syntax.thy
     1.1 --- a/src/HOL/Hoare_Parallel/OG_Syntax.thy	Thu Feb 11 09:14:34 2010 +0100
     1.2 +++ b/src/HOL/Hoare_Parallel/OG_Syntax.thy	Thu Feb 11 13:54:53 2010 +0100
     1.3 @@ -5,18 +5,25 @@
     1.4  text{* Syntax for commands and for assertions and boolean expressions in 
     1.5   commands @{text com} and annotated commands @{text ann_com}. *}
     1.6  
     1.7 +abbreviation Skip :: "'a com"  ("SKIP" 63)
     1.8 +  where "SKIP \<equiv> Basic id"
     1.9 +
    1.10 +abbreviation AnnSkip :: "'a assn \<Rightarrow> 'a ann_com"  ("_//SKIP" [90] 63)
    1.11 +  where "r SKIP \<equiv> AnnBasic r id"
    1.12 +
    1.13 +notation
    1.14 +  Seq  ("_,,/ _" [55, 56] 55) and
    1.15 +  AnnSeq  ("_;;/ _" [60,61] 60)
    1.16 +
    1.17  syntax
    1.18    "_Assign"      :: "idt \<Rightarrow> 'b \<Rightarrow> 'a com"    ("(\<acute>_ :=/ _)" [70, 65] 61)
    1.19    "_AnnAssign"   :: "'a assn \<Rightarrow> idt \<Rightarrow> 'b \<Rightarrow> 'a com"    ("(_ \<acute>_ :=/ _)" [90,70,65] 61)
    1.20  
    1.21  translations
    1.22 -  "\<acute>\<spacespace>x := a" \<rightharpoonup> "Basic \<guillemotleft>\<acute>\<spacespace>(_update_name x (\<lambda>_. a))\<guillemotright>"
    1.23 -  "r \<acute>\<spacespace>x := a" \<rightharpoonup> "AnnBasic r \<guillemotleft>\<acute>\<spacespace>(_update_name x (\<lambda>_. a))\<guillemotright>"
    1.24 +  "\<acute>x := a" \<rightharpoonup> "CONST Basic \<guillemotleft>\<acute>(_update_name x (\<lambda>_. a))\<guillemotright>"
    1.25 +  "r \<acute>x := a" \<rightharpoonup> "CONST AnnBasic r \<guillemotleft>\<acute>(_update_name x (\<lambda>_. a))\<guillemotright>"
    1.26  
    1.27  syntax
    1.28 -  "_AnnSkip"     :: "'a assn \<Rightarrow> 'a ann_com"              ("_//SKIP" [90] 63)
    1.29 -  "_AnnSeq"      :: "'a ann_com \<Rightarrow> 'a ann_com \<Rightarrow> 'a ann_com"  ("_;;/ _" [60,61] 60)
    1.30 -  
    1.31    "_AnnCond1"    :: "'a assn \<Rightarrow> 'a bexp  \<Rightarrow> 'a ann_com  \<Rightarrow> 'a ann_com \<Rightarrow> 'a ann_com"
    1.32                      ("_ //IF _ /THEN _ /ELSE _ /FI"  [90,0,0,0] 61)
    1.33    "_AnnCond2"    :: "'a assn \<Rightarrow> 'a bexp  \<Rightarrow> 'a ann_com \<Rightarrow> 'a ann_com"
    1.34 @@ -28,8 +35,6 @@
    1.35    "_AnnAtom"     :: "'a assn  \<Rightarrow> 'a com \<Rightarrow> 'a ann_com"   ("_//\<langle>_\<rangle>" [90,0] 61)
    1.36    "_AnnWait"     :: "'a assn \<Rightarrow> 'a bexp \<Rightarrow> 'a ann_com"   ("_//WAIT _ END" [90,0] 61)
    1.37  
    1.38 -  "_Skip"        :: "'a com"                 ("SKIP" 63)
    1.39 -  "_Seq"         :: "'a com \<Rightarrow> 'a com \<Rightarrow> 'a com" ("_,,/ _" [55, 56] 55)
    1.40    "_Cond"        :: "'a bexp \<Rightarrow> 'a com \<Rightarrow> 'a com \<Rightarrow> 'a com" 
    1.41                                    ("(0IF _/ THEN _/ ELSE _/ FI)" [0, 0, 0] 61)
    1.42    "_Cond2"       :: "'a bexp \<Rightarrow> 'a com \<Rightarrow> 'a com"   ("IF _ THEN _ FI" [0,0] 56)
    1.43 @@ -39,20 +44,15 @@
    1.44                      ("(0WHILE _ //DO _ /OD)"  [0, 0] 61)
    1.45  
    1.46  translations
    1.47 -  "SKIP" \<rightleftharpoons> "Basic id"
    1.48 -  "c_1,, c_2" \<rightleftharpoons> "Seq c_1 c_2"
    1.49 -
    1.50 -  "IF b THEN c1 ELSE c2 FI" \<rightharpoonup> "Cond .{b}. c1 c2"
    1.51 +  "IF b THEN c1 ELSE c2 FI" \<rightharpoonup> "CONST Cond .{b}. c1 c2"
    1.52    "IF b THEN c FI" \<rightleftharpoons> "IF b THEN c ELSE SKIP FI"
    1.53    "WHILE b INV i DO c OD" \<rightharpoonup> "While .{b}. i c"
    1.54    "WHILE b DO c OD" \<rightleftharpoons> "WHILE b INV CONST undefined DO c OD"
    1.55  
    1.56 -  "r SKIP" \<rightleftharpoons> "AnnBasic r id"
    1.57 -  "c_1;; c_2" \<rightleftharpoons> "AnnSeq c_1 c_2" 
    1.58 -  "r IF b THEN c1 ELSE c2 FI" \<rightharpoonup> "AnnCond1 r .{b}. c1 c2"
    1.59 -  "r IF b THEN c FI" \<rightharpoonup> "AnnCond2 r .{b}. c"
    1.60 -  "r WHILE b INV i DO c OD" \<rightharpoonup> "AnnWhile r .{b}. i c"
    1.61 -  "r AWAIT b THEN c END" \<rightharpoonup> "AnnAwait r .{b}. c"
    1.62 +  "r IF b THEN c1 ELSE c2 FI" \<rightharpoonup> "CONST AnnCond1 r .{b}. c1 c2"
    1.63 +  "r IF b THEN c FI" \<rightharpoonup> "CONST AnnCond2 r .{b}. c"
    1.64 +  "r WHILE b INV i DO c OD" \<rightharpoonup> "CONST AnnWhile r .{b}. i c"
    1.65 +  "r AWAIT b THEN c END" \<rightharpoonup> "CONST AnnAwait r .{b}. c"
    1.66    "r \<langle>c\<rangle>" \<rightleftharpoons> "r AWAIT True THEN c END"
    1.67    "r WAIT b END" \<rightleftharpoons> "r AWAIT b THEN SKIP END"
    1.68   
    1.69 @@ -68,11 +68,11 @@
    1.70                    ("SCHEME [_ \<le> _ < _] _// _" [0,0,0,60, 90] 57)
    1.71  
    1.72  translations
    1.73 -  "_prg c q" \<rightleftharpoons> "[(Some c, q)]"
    1.74 -  "_prgs c q ps" \<rightleftharpoons> "(Some c, q) # ps"
    1.75 -  "_PAR ps" \<rightleftharpoons> "Parallel ps"
    1.76 +  "_prg c q" \<rightleftharpoons> "[(CONST Some c, q)]"
    1.77 +  "_prgs c q ps" \<rightleftharpoons> "(CONST Some c, q) # ps"
    1.78 +  "_PAR ps" \<rightleftharpoons> "CONST Parallel ps"
    1.79  
    1.80 -  "_prg_scheme j i k c q" \<rightleftharpoons> "CONST map (\<lambda>i. (Some c, q)) [j..<k]"
    1.81 +  "_prg_scheme j i k c q" \<rightleftharpoons> "CONST map (\<lambda>i. (CONST Some c, q)) [j..<k]"
    1.82  
    1.83  print_translation {*
    1.84    let
    1.85 @@ -86,11 +86,11 @@
    1.86  
    1.87      val assert_tr' = quote_tr' (Syntax.const "_Assert");
    1.88  
    1.89 -    fun bexp_tr' name ((Const ("Collect", _) $ t) :: ts) =
    1.90 +    fun bexp_tr' name ((Const (@{const_syntax Collect}, _) $ t) :: ts) =
    1.91            quote_tr' (Syntax.const name) (t :: ts)
    1.92        | bexp_tr' _ _ = raise Match;
    1.93  
    1.94 -    fun annbexp_tr' name (r :: (Const ("Collect", _) $ t) :: ts) =
    1.95 +    fun annbexp_tr' name (r :: (Const (@{const_syntax Collect}, _) $ t) :: ts) =
    1.96            annquote_tr' (Syntax.const name) (r :: t :: ts)
    1.97        | annbexp_tr' _ _ = raise Match;
    1.98  
    1.99 @@ -105,8 +105,10 @@
   1.100        | update_name_tr' (Const x) = Const (upd_tr' x)
   1.101        | update_name_tr' _ = raise Match;
   1.102  
   1.103 -    fun K_tr' (Abs (_,_,t)) = if null (loose_bnos t) then t else raise Match
   1.104 -      | K_tr' (Abs (_,_,Abs (_,_,t)$Bound 0)) = if null (loose_bnos t) then t else raise Match
   1.105 +    fun K_tr' (Abs (_, _, t)) =
   1.106 +          if null (loose_bnos t) then t else raise Match
   1.107 +      | K_tr' (Abs (_, _, Abs (_, _, t) $ Bound 0)) =
   1.108 +          if null (loose_bnos t) then t else raise Match
   1.109        | K_tr' _ = raise Match;
   1.110  
   1.111      fun assign_tr' (Abs (x, _, f $ k $ Bound 0) :: ts) =
   1.112 @@ -119,22 +121,26 @@
   1.113              (Abs (x, dummyT, K_tr' k) :: ts)
   1.114        | annassign_tr' _ = raise Match;
   1.115  
   1.116 -    fun Parallel_PAR [(Const ("Cons",_) $ (Const ("Pair",_) $ (Const ("Some",_) $ t1 ) $ t2) $ Const ("Nil",_))] = 
   1.117 -                   (Syntax.const "_prg" $ t1 $ t2)
   1.118 -      | Parallel_PAR [(Const ("Cons",_) $ (Const ("Pair",_) $ (Const ("Some",_) $ t1) $ t2) $ ts)] =
   1.119 -                     (Syntax.const "_prgs" $ t1 $ t2 $ Parallel_PAR [ts])
   1.120 +    fun Parallel_PAR [(Const (@{const_syntax Cons}, _) $
   1.121 +            (Const (@{const_syntax Pair}, _) $ (Const (@{const_syntax Some},_) $ t1 ) $ t2) $
   1.122 +            Const (@{const_syntax Nil}, _))] = Syntax.const "_prg" $ t1 $ t2
   1.123 +      | Parallel_PAR [(Const (@{const_syntax Cons}, _) $
   1.124 +            (Const (@{const_syntax Pair}, _) $ (Const (@{const_syntax Some}, _) $ t1) $ t2) $ ts)] =
   1.125 +          Syntax.const "_prgs" $ t1 $ t2 $ Parallel_PAR [ts]
   1.126        | Parallel_PAR _ = raise Match;
   1.127  
   1.128 -fun Parallel_tr' ts = Syntax.const "_PAR" $ Parallel_PAR ts;
   1.129 +    fun Parallel_tr' ts = Syntax.const "_PAR" $ Parallel_PAR ts;
   1.130    in
   1.131 -    [("Collect", assert_tr'), ("Basic", assign_tr'), 
   1.132 -      ("Cond", bexp_tr' "_Cond"), ("While", bexp_tr' "_While_inv"),
   1.133 -      ("AnnBasic", annassign_tr'), 
   1.134 -      ("AnnWhile", annbexp_tr' "_AnnWhile"), ("AnnAwait", annbexp_tr' "_AnnAwait"),
   1.135 -      ("AnnCond1", annbexp_tr' "_AnnCond1"), ("AnnCond2", annbexp_tr' "_AnnCond2")]
   1.136 -
   1.137 -  end
   1.138 -
   1.139 +   [(@{const_syntax Collect}, assert_tr'),
   1.140 +    (@{const_syntax Basic}, assign_tr'),
   1.141 +    (@{const_syntax Cond}, bexp_tr' "_Cond"),
   1.142 +    (@{const_syntax While}, bexp_tr' "_While_inv"),
   1.143 +    (@{const_syntax AnnBasic}, annassign_tr'),
   1.144 +    (@{const_syntax AnnWhile}, annbexp_tr' "_AnnWhile"),
   1.145 +    (@{const_syntax AnnAwait}, annbexp_tr' "_AnnAwait"),
   1.146 +    (@{const_syntax AnnCond1}, annbexp_tr' "_AnnCond1"),
   1.147 +    (@{const_syntax AnnCond2}, annbexp_tr' "_AnnCond2")]
   1.148 +  end;
   1.149  *}
   1.150  
   1.151  end
   1.152 \ No newline at end of file
     2.1 --- a/src/HOL/Hoare_Parallel/OG_Tran.thy	Thu Feb 11 09:14:34 2010 +0100
     2.2 +++ b/src/HOL/Hoare_Parallel/OG_Tran.thy	Thu Feb 11 13:54:53 2010 +0100
     2.3 @@ -69,7 +69,7 @@
     2.4  
     2.5  monos "rtrancl_mono"
     2.6  
     2.7 -text {* The corresponding syntax translations are: *}
     2.8 +text {* The corresponding abbreviations are: *}
     2.9  
    2.10  abbreviation
    2.11    ann_transition_n :: "('a ann_com_op \<times> 'a) \<Rightarrow> nat \<Rightarrow> ('a ann_com_op \<times> 'a) 
    2.12 @@ -101,8 +101,8 @@
    2.13    SEM :: "'a com \<Rightarrow> 'a set \<Rightarrow> 'a set"
    2.14    "SEM c S \<equiv> \<Union>sem c ` S "
    2.15  
    2.16 -syntax "_Omega" :: "'a com"    ("\<Omega>" 63)
    2.17 -translations  "\<Omega>" \<rightleftharpoons> "While CONST UNIV CONST UNIV (Basic id)"
    2.18 +abbreviation Omega :: "'a com"    ("\<Omega>" 63)
    2.19 +  where "\<Omega> \<equiv> While UNIV UNIV (Basic id)"
    2.20  
    2.21  consts fwhile :: "'a bexp \<Rightarrow> 'a com \<Rightarrow> nat \<Rightarrow> 'a com"
    2.22  primrec 
     3.1 --- a/src/HOL/Hoare_Parallel/Quote_Antiquote.thy	Thu Feb 11 09:14:34 2010 +0100
     3.2 +++ b/src/HOL/Hoare_Parallel/Quote_Antiquote.thy	Thu Feb 11 13:54:53 2010 +0100
     3.3 @@ -12,7 +12,7 @@
     3.4    "_Assert"    :: "'a \<Rightarrow> 'a set"            ("(\<lbrace>_\<rbrace>)" [0] 1000)
     3.5  
     3.6  translations
     3.7 -  ".{b}." \<rightharpoonup> "Collect \<guillemotleft>b\<guillemotright>"
     3.8 +  ".{b}." \<rightharpoonup> "CONST Collect \<guillemotleft>b\<guillemotright>"
     3.9  
    3.10  parse_translation {*
    3.11    let
     4.1 --- a/src/HOL/Hoare_Parallel/RG_Syntax.thy	Thu Feb 11 09:14:34 2010 +0100
     4.2 +++ b/src/HOL/Hoare_Parallel/RG_Syntax.thy	Thu Feb 11 13:54:53 2010 +0100
     4.3 @@ -4,10 +4,13 @@
     4.4  imports RG_Hoare Quote_Antiquote
     4.5  begin
     4.6  
     4.7 +abbreviation Skip :: "'a com"  ("SKIP")
     4.8 +  where "SKIP \<equiv> Basic id"
     4.9 +
    4.10 +notation Seq  ("(_;;/ _)" [60,61] 60)
    4.11 +
    4.12  syntax
    4.13    "_Assign"    :: "idt \<Rightarrow> 'b \<Rightarrow> 'a com"                     ("(\<acute>_ :=/ _)" [70, 65] 61)
    4.14 -  "_skip"      :: "'a com"                                  ("SKIP")
    4.15 -  "_Seq"       :: "'a com \<Rightarrow> 'a com \<Rightarrow> 'a com"              ("(_;;/ _)" [60,61] 60)
    4.16    "_Cond"      :: "'a bexp \<Rightarrow> 'a com \<Rightarrow> 'a com \<Rightarrow> 'a com"   ("(0IF _/ THEN _/ ELSE _/FI)" [0, 0, 0] 61)
    4.17    "_Cond2"     :: "'a bexp \<Rightarrow> 'a com \<Rightarrow> 'a com"             ("(0IF _ THEN _ FI)" [0,0] 56)
    4.18    "_While"     :: "'a bexp \<Rightarrow> 'a com \<Rightarrow> 'a com"             ("(0WHILE _ /DO _ /OD)"  [0, 0] 61)
    4.19 @@ -16,9 +19,7 @@
    4.20    "_Wait"      :: "'a bexp \<Rightarrow> 'a com"                       ("(0WAIT _ END)" 61)
    4.21  
    4.22  translations
    4.23 -  "\<acute>\<spacespace>x := a" \<rightharpoonup> "Basic \<guillemotleft>\<acute>\<spacespace>(_update_name x (\<lambda>_. a))\<guillemotright>"
    4.24 -  "SKIP" \<rightleftharpoons> "Basic id"
    4.25 -  "c1;; c2" \<rightleftharpoons> "Seq c1 c2"
    4.26 +  "\<acute>x := a" \<rightharpoonup> "CONST Basic \<guillemotleft>\<acute>(_update_name x (\<lambda>_. a))\<guillemotright>"
    4.27    "IF b THEN c1 ELSE c2 FI" \<rightharpoonup> "Cond .{b}. c1 c2"
    4.28    "IF b THEN c FI" \<rightleftharpoons> "IF b THEN c ELSE SKIP FI"
    4.29    "WHILE b DO c OD" \<rightharpoonup> "While .{b}. c"
    4.30 @@ -52,8 +53,8 @@
    4.31    "_after"  :: "id \<Rightarrow> 'a" ("\<ordfeminine>_")
    4.32   
    4.33  translations
    4.34 -  "\<ordmasculine>x" \<rightleftharpoons> "x \<acute>fst"
    4.35 -  "\<ordfeminine>x" \<rightleftharpoons> "x \<acute>snd"
    4.36 +  "\<ordmasculine>x" \<rightleftharpoons> "x \<acute>CONST fst"
    4.37 +  "\<ordfeminine>x" \<rightleftharpoons> "x \<acute>CONST snd"
    4.38  
    4.39  print_translation {*
    4.40    let
    4.41 @@ -63,7 +64,7 @@
    4.42  
    4.43      val assert_tr' = quote_tr' (Syntax.const "_Assert");
    4.44  
    4.45 -    fun bexp_tr' name ((Const ("Collect", _) $ t) :: ts) =
    4.46 +    fun bexp_tr' name ((Const (@{const_syntax Collect}, _) $ t) :: ts) =
    4.47            quote_tr' (Syntax.const name) (t :: ts)
    4.48        | bexp_tr' _ _ = raise Match;
    4.49  
    4.50 @@ -78,8 +79,10 @@
    4.51        | update_name_tr' (Const x) = Const (upd_tr' x)
    4.52        | update_name_tr' _ = raise Match;
    4.53  
    4.54 -    fun K_tr' (Abs (_,_,t)) = if null (loose_bnos t) then t else raise Match
    4.55 -      | K_tr' (Abs (_,_,Abs (_,_,t)$Bound 0)) = if null (loose_bnos t) then t else raise Match
    4.56 +    fun K_tr' (Abs (_, _, t)) =
    4.57 +          if null (loose_bnos t) then t else raise Match
    4.58 +      | K_tr' (Abs (_, _, Abs (_, _, t) $ Bound 0)) =
    4.59 +          if null (loose_bnos t) then t else raise Match
    4.60        | K_tr' _ = raise Match;
    4.61  
    4.62      fun assign_tr' (Abs (x, _, f $ k $ Bound 0) :: ts) =
    4.63 @@ -87,8 +90,10 @@
    4.64              (Abs (x, dummyT, K_tr' k) :: ts)
    4.65        | assign_tr' _ = raise Match;
    4.66    in
    4.67 -    [("Collect", assert_tr'), ("Basic", assign_tr'),
    4.68 -      ("Cond", bexp_tr' "_Cond"), ("While", bexp_tr' "_While_inv")]
    4.69 +   [(@{const_syntax Collect}, assert_tr'),
    4.70 +    (@{const_syntax Basic}, assign_tr'),
    4.71 +    (@{const_syntax Cond}, bexp_tr' "_Cond"),
    4.72 +    (@{const_syntax While}, bexp_tr' "_While_inv")]
    4.73    end
    4.74  *}
    4.75