src/HOL/Hoare/Hoare.thy
author paulson
Fri, 19 Sep 1997 16:12:21 +0200
changeset 3685 5b8c0c8f576e
parent 2901 4e92704cf320
child 3842 b55686a7b22c
permissions -rw-r--r--
Full version of TLS including session resumption, but no Oops
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
     1
(*  Title:      HOL/Hoare/Hoare.thy
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
     3
    Author:     Norbert Galm & Tobias Nipkow
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
     4
    Copyright   1995 TUM
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
     5
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
     6
Sugared semantic embedding of Hoare logic.
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
     7
*)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
     8
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
     9
Hoare = Arith +
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    10
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    11
types
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    12
  'a prog                       (* program syntax *)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    13
  pvar = nat                    (* encoding of program variables ( < 26! ) *)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    14
  'a state = pvar => 'a         (* program state *)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    15
  'a exp = 'a state => 'a       (* denotation of expressions *)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    16
  'a bexp = 'a state => bool    (* denotation of boolean expressions *)
1384
007ad29ce6ca removed quotes from types section
clasohm
parents: 1374
diff changeset
    17
  'a com = 'a state => 'a state => bool (* denotation of programs *)
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    18
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    19
syntax
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    20
  "@Skip"       :: 'a prog                              ("SKIP")
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    21
  "@Assign"     :: [id, 'a] => 'a prog          ("_ := _")
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    22
  "@Seq"        :: ['a prog, 'a prog] => 'a prog        ("_;//_" [0,1000] 999)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    23
  "@If"         :: [bool, 'a prog, 'a prog] => 'a prog
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    24
                   ("IF _//THEN//  (_)//ELSE//  (_)//END")
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    25
  "@While"      :: [bool, bool, 'a prog] => 'a prog
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    26
                   ("WHILE _//DO {_}//  (_)//END")
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    27
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    28
  "@Spec"       :: [bool, 'a prog, bool] => bool        ("{_}//_//{_}")
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    29
1558
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    30
constdefs
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    31
  (* denotational semantics *)
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    32
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    33
  Skip          :: 'a com
1558
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    34
  "Skip s s' == (s=s')"
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    35
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    36
  Assign        :: [pvar, 'a exp] => 'a com
1558
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    37
  "Assign v e s s' == (s' = (%x.if x=v then e(s) else s(x)))"
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    38
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    39
  Seq           :: ['a com, 'a com] => 'a com
1558
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    40
  "Seq c c' s s' == ? s''. c s s'' & c' s'' s'"
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    41
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    42
  Cond          :: ['a bexp, 'a com, 'a com] => 'a com
1558
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    43
  "Cond b c c' s s' == (b(s) --> c s s') & (~b s --> c' s s')"
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    44
2901
4e92704cf320 renamed variable 'inv'
nipkow
parents: 2708
diff changeset
    45
consts
4e92704cf320 renamed variable 'inv'
nipkow
parents: 2708
diff changeset
    46
  Iter          :: [nat, 'a bexp, 'a com] => 'a com
4e92704cf320 renamed variable 'inv'
nipkow
parents: 2708
diff changeset
    47
primrec Iter nat
4e92704cf320 renamed variable 'inv'
nipkow
parents: 2708
diff changeset
    48
  "Iter 0 b c = (%s s'.~b(s) & (s=s'))"
4e92704cf320 renamed variable 'inv'
nipkow
parents: 2708
diff changeset
    49
  "Iter (Suc n) b c = (%s s'. b(s) & Seq c (Iter n b c) s s')"
1558
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    50
2901
4e92704cf320 renamed variable 'inv'
nipkow
parents: 2708
diff changeset
    51
constdefs
4e92704cf320 renamed variable 'inv'
nipkow
parents: 2708
diff changeset
    52
  While         :: ['a bexp, 'a bexp, 'a com] => 'a com
4e92704cf320 renamed variable 'inv'
nipkow
parents: 2708
diff changeset
    53
  "While b I c s s' == ? n. Iter n b c s s'"
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    54
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    55
  Spec          :: ['a bexp, 'a com, 'a bexp] => bool
1558
9c6ebfab4e05 added constdefs section
clasohm
parents: 1476
diff changeset
    56
  "Spec p c q == !s s'. c s s' --> p s --> q s'"
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    57
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    58
end
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    59
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    60
ML
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    61
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    62
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    63
(*** term manipulation ***)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    64
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    65
(* name_in_term:bool (name:string,trm:term) bestimmt, ob in trm der Name name als Konstante,
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    66
   freie Var., scheme-Variable oder als Name fuer eine Lambda-Abstraktion vorkommt *)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    67
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    68
fun name_in_term (name,Const (s,t))     =(name=s)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    69
  | name_in_term (name,Free (s,t))      =(name=s)
2239
8f9007a2f165 Replaced obsolete "makestring" by Int.toString
paulson
parents: 1824
diff changeset
    70
  | name_in_term (name,Var ((s,i),t))   =(name=s ^ Int.toString i)
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    71
  | name_in_term (name,Abs (s,t,trm))   =(name=s) orelse (name_in_term (name,trm))
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    72
  | name_in_term (name,trm1 $ trm2)     =(name_in_term (name,trm1)) orelse (name_in_term (name,trm2))
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    73
  | name_in_term (_,_)                  =false;
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    74
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    75
(* variant_name:string (name:string,trm:term) liefert einen von name abgewandelten Namen (durch Anhaengen
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    76
   von genuegend vielen "_"), der nicht in trm vorkommt. Im Gegensatz zu variant_abs beruecktsichtigt es
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    77
   auch Namen von scheme-Variablen und von Lambda-Abstraktionen in trm *)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    78
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    79
fun variant_name (name,trm)     =if name_in_term (name,trm)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    80
                                        then variant_name (name ^ "_",trm)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    81
                                        else name;
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    82
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    83
(* subst_term:term (von:term,nach:term,trm:term) liefert den Term, der aus
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    84
trm entsteht, wenn alle Teilterme, die gleich von sind, durch nach ersetzt
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    85
wurden *)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    86
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    87
fun subst_term (von,nach,Abs (s,t,trm)) =if von=Abs (s,t,trm)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    88
                                                then nach
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    89
                                                else Abs (s,t,subst_term (von,nach,trm))
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    90
  | subst_term (von,nach,trm1 $ trm2)   =if von=trm1 $ trm2
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    91
                                                then nach
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    92
                                                else subst_term (von,nach,trm1) $ subst_term (von,nach,trm2)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    93
  | subst_term (von,nach,trm)           =if von=trm
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    94
                                                then nach
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
    95
                                                else trm;
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    96
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    97
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    98
(* Translation between program vars ("a" - "z") and their encoding as
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
    99
   natural numbers: "a" <==> 0, "b" <==> Suc(0), ..., "z" <==> 25 *)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   100
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   101
fun is_pvarID s = size s=1 andalso "a"<=s andalso s<="z";
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   102
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   103
fun pvarID2pvar s =
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   104
  let fun rest2pvar (i,arg) =
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   105
            if i=0 then arg else rest2pvar(i-1, Syntax.const "Suc" $ arg)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   106
  in rest2pvar(ord s - ord "a", Syntax.const "0") end;
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   107
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   108
fun pvar2pvarID trm     =
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   109
        let
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   110
                fun rest2pvarID (Const("0",_),i)                =chr (i + ord "a")
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   111
                  | rest2pvarID (Const("Suc",_) $ trm,i)        =rest2pvarID (trm,i+1)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   112
        in
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   113
                rest2pvarID (trm,0)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   114
        end;
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   115
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   116
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   117
(*** parse translations: syntax -> semantics ***)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   118
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   119
(* term_tr:term (name:string,trm:term) ersetzt in trm alle freien Variablen, die eine pvarID
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   120
   darstellen, durch name $ pvarID2pvar(pvarID). Beispiel:
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   121
   bei name="s" und dem Term "a=b & a=X" wird der Term "s(0)=s(Suc(0)) & s(0)=X" geliefert *)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   122
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   123
fun term_tr (name,Free (s,t)) = if is_pvarID s
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   124
                                then Syntax.free name $ pvarID2pvar s
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   125
                                else Free (s,t)
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   126
  | term_tr (name,Abs (s,t,trm)) = Abs (s,t,term_tr (name,trm))
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   127
  | term_tr (name,trm1 $ trm2)  = term_tr (name,trm1) $ term_tr (name,trm2)
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   128
  | term_tr (name,trm) = trm;
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   129
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   130
fun bool_tr B =
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   131
  let val name = variant_name("s",B)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   132
  in Abs (name,dummyT,abstract_over (Syntax.free name,term_tr (name,B))) end;
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   133
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   134
fun exp_tr E =
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   135
  let val name = variant_name("s",E)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   136
  in Abs (name,dummyT,abstract_over (Syntax.free name,term_tr (name,E))) end;
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   137
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   138
fun prog_tr (Const ("@Skip",_)) = Syntax.const "Skip"
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   139
  | prog_tr (Const ("@Assign",_) $ Free (V,_) $ E) =
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   140
      if is_pvarID V
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   141
      then Syntax.const "Assign" $ pvarID2pvar V $ exp_tr E
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   142
      else error("Not a valid program variable: " ^ quote V)
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   143
  | prog_tr (Const ("@Seq",_) $ C $ C') =
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   144
      Syntax.const "Seq" $ prog_tr C $ prog_tr C'
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   145
  | prog_tr (Const ("@If",_) $ B $ C $ C') =
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   146
      Syntax.const "Cond" $ bool_tr B $ prog_tr C $ prog_tr C'
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   147
  | prog_tr (Const ("@While",_) $ B $ INV $ C) =
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   148
      Syntax.const "While" $ bool_tr B $ bool_tr INV $ prog_tr C;
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   149
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   150
fun spec_tr [P,C,Q] = Syntax.const "Spec" $ bool_tr P $ prog_tr C $ bool_tr Q;
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   151
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   152
val parse_translation = [("@Spec",spec_tr)];
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   153
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   154
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   155
(*** print translations: semantics -> syntax ***)
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   156
2708
c3b86dcd340a added comment: print translations do not mark tokens;
wenzelm
parents: 2239
diff changeset
   157
(* Note: does not mark tokens *)
c3b86dcd340a added comment: print translations do not mark tokens;
wenzelm
parents: 2239
diff changeset
   158
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   159
(* term_tr':term (name:string,trm:term) ersetzt in trm alle Vorkommen von name $ pvar durch
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   160
   entsprechende freie Variablen, welche die pvarID zu pvar darstellen. Beispiel:
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   161
        bei name="s" und dem Term "s(0)=s(Suc(0)) & s(0)=X" wird der Term "a=b & a=X" geliefert *)
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   162
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   163
fun term_tr' (name,Free (s,t) $ trm)    =if name=s
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   164
                                                then Syntax.free (pvar2pvarID trm)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   165
                                                else Free (s,t) $ term_tr' (name,trm)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   166
  | term_tr' (name,Abs (s,t,trm))       =Abs (s,t,term_tr' (name,trm))
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   167
  | term_tr' (name,trm1 $ trm2)         =term_tr' (name,trm1) $ term_tr' (name,trm2)
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   168
  | term_tr' (name,trm)                 =trm;
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   169
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   170
fun bexp_tr' (Abs(_,_,b))       =term_tr' (variant_abs ("s",dummyT,b));
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   171
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   172
fun exp_tr' (Abs(_,_,e))        =term_tr' (variant_abs ("s",dummyT,e));
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   173
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   174
fun com_tr' (Const ("Skip",_))                  =Syntax.const "@Skip"
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   175
  | com_tr' (Const ("Assign",_) $ v $ e)                =Syntax.const "@Assign" $ Syntax.free (pvar2pvarID v) $ exp_tr' e
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   176
  | com_tr' (Const ("Seq",_) $ c $ c')          =Syntax.const "@Seq" $ com_tr' c $ com_tr' c'
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   177
  | com_tr' (Const ("Cond",_) $ b $ c $ c')             =Syntax.const "@If" $ bexp_tr' b $ com_tr' c $ com_tr' c'
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   178
  | com_tr' (Const ("While",_) $ b $ inv $ c)   =Syntax.const "@While" $ bexp_tr' b $ bexp_tr' inv $ com_tr' c;
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   179
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   180
fun spec_tr' [p,c,q]            =Syntax.const "@Spec" $ bexp_tr' p $ com_tr' c $ bexp_tr' q;
1335
5e1c0540f285 New directory.
nipkow
parents:
diff changeset
   181
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1384
diff changeset
   182
val print_translation   =[("Spec",spec_tr')];