src/HOL/IMP/Hoare.thy
author clasohm
Wed Nov 29 17:01:41 1995 +0100 (1995-11-29)
changeset 1374 5e407f2a3323
parent 972 e61b058d58d2
child 1447 bc2c0acbbf29
permissions -rw-r--r--
removed quotes from consts and syntax sections
nipkow@936
     1
(*  Title: 	HOL/IMP/Hoare.thy
nipkow@938
     2
    ID:         $Id$
nipkow@936
     3
    Author: 	Tobias Nipkow
nipkow@936
     4
    Copyright   1995 TUM
nipkow@936
     5
nipkow@936
     6
Semantic embedding of Hoare logic
nipkow@936
     7
*)
nipkow@936
     8
nipkow@936
     9
Hoare = Denotation +
nipkow@936
    10
consts
clasohm@1374
    11
  spec :: [state=>bool,com,state=>bool] => bool
clasohm@1374
    12
(* syntax "@spec" :: [bool,com,bool] => bool *)
nipkow@939
    13
          ("{{(1_)}}/ (_)/ {{(1_)}}" 10)
nipkow@936
    14
defs
clasohm@972
    15
  spec_def "spec P c Q == !s t. (s,t) : C(c) --> P s --> Q t"
nipkow@936
    16
end
nipkow@939
    17
(* Pretty-printing of assertions.
nipkow@939
    18
   Not very helpful as long as programs are not pretty-printed.
nipkow@939
    19
ML
nipkow@939
    20
nipkow@939
    21
local open Syntax
nipkow@939
    22
nipkow@939
    23
fun is_loc a = let val ch = hd(explode a)
nipkow@939
    24
               in ord "A" <= ord ch andalso ord ch <= ord "Z" end;
nipkow@939
    25
nipkow@939
    26
fun tr(s$t,i) = tr(s,i)$tr(t,i)
nipkow@939
    27
  | tr(Abs(x,T,u),i) = Abs(x,T,tr(u,i+1))
nipkow@939
    28
  | tr(t as Free(a,T),i) = if is_loc a then Bound(i) $ free(a) else t
nipkow@939
    29
  | tr(t,_) = t;
nipkow@939
    30
nipkow@939
    31
fun cond_tr(p) = Abs("",dummyT,tr(p,0))
nipkow@939
    32
nipkow@939
    33
fun spec_tr[p,c,q] = const"spec" $ cond_tr p $ c $ cond_tr q;
nipkow@939
    34
nipkow@939
    35
fun tr'(t as (Bound j $ (u as Free(a,_))),i) = if i=j then u else t
nipkow@939
    36
  | tr'(s$t,i) = tr'(s,i)$tr'(t,i)
nipkow@939
    37
  | tr'(Abs(x,T,u),i) = Abs(x,T,tr'(u,i+1))
nipkow@939
    38
  | tr'(t,_) = t;
nipkow@939
    39
nipkow@939
    40
fun spec_tr'[Abs(_,_,p),c,Abs(_,_,q)] =
nipkow@939
    41
  const"@spec" $ tr'(p,0) $ c $ tr'(q,0);
nipkow@939
    42
nipkow@939
    43
in
nipkow@939
    44
nipkow@939
    45
val parse_translation = [("@spec", spec_tr)];
nipkow@939
    46
val print_translation = [("spec", spec_tr')];
nipkow@939
    47
nipkow@939
    48
end
nipkow@939
    49
*)