src/HOL/IMP/Hoare.thy
changeset 939 534955033ed2
parent 938 621be7ec81d7
child 972 e61b058d58d2
     1.1 --- a/src/HOL/IMP/Hoare.thy	Tue Mar 07 15:00:34 1995 +0100
     1.2 +++ b/src/HOL/IMP/Hoare.thy	Wed Mar 08 10:25:50 1995 +0100
     1.3 @@ -8,7 +8,42 @@
     1.4  
     1.5  Hoare = Denotation +
     1.6  consts
     1.7 -  spec:: "[state=>bool,com,state=>bool] => bool" ("{{(1_)}}/ (_)/ {{(1_)}}" 10)
     1.8 +  spec :: "[state=>bool,com,state=>bool] => bool"
     1.9 +(* syntax "@spec" :: "[bool,com,bool] => bool" *)
    1.10 +          ("{{(1_)}}/ (_)/ {{(1_)}}" 10)
    1.11  defs
    1.12    spec_def "spec P c Q == !s t. <s,t> : C(c) --> P s --> Q t"
    1.13  end
    1.14 +(* Pretty-printing of assertions.
    1.15 +   Not very helpful as long as programs are not pretty-printed.
    1.16 +ML
    1.17 +
    1.18 +local open Syntax
    1.19 +
    1.20 +fun is_loc a = let val ch = hd(explode a)
    1.21 +               in ord "A" <= ord ch andalso ord ch <= ord "Z" end;
    1.22 +
    1.23 +fun tr(s$t,i) = tr(s,i)$tr(t,i)
    1.24 +  | tr(Abs(x,T,u),i) = Abs(x,T,tr(u,i+1))
    1.25 +  | tr(t as Free(a,T),i) = if is_loc a then Bound(i) $ free(a) else t
    1.26 +  | tr(t,_) = t;
    1.27 +
    1.28 +fun cond_tr(p) = Abs("",dummyT,tr(p,0))
    1.29 +
    1.30 +fun spec_tr[p,c,q] = const"spec" $ cond_tr p $ c $ cond_tr q;
    1.31 +
    1.32 +fun tr'(t as (Bound j $ (u as Free(a,_))),i) = if i=j then u else t
    1.33 +  | tr'(s$t,i) = tr'(s,i)$tr'(t,i)
    1.34 +  | tr'(Abs(x,T,u),i) = Abs(x,T,tr'(u,i+1))
    1.35 +  | tr'(t,_) = t;
    1.36 +
    1.37 +fun spec_tr'[Abs(_,_,p),c,Abs(_,_,q)] =
    1.38 +  const"@spec" $ tr'(p,0) $ c $ tr'(q,0);
    1.39 +
    1.40 +in
    1.41 +
    1.42 +val parse_translation = [("@spec", spec_tr)];
    1.43 +val print_translation = [("spec", spec_tr')];
    1.44 +
    1.45 +end
    1.46 +*)