src/HOL/IMP/VC.thy
author berghofe
Thu Aug 08 11:34:29 1996 +0200 (1996-08-08)
changeset 1900 c7a869229091
parent 1696 e84bff5c519b
child 2810 c4e16b36bc57
permissions -rw-r--r--
Simplified primrec definitions.
     1 (*  Title:      HOL/IMP/VC.thy
     2     ID:         $Id$
     3     Author:     Tobias Nipkow
     4     Copyright   1996 TUM
     5 
     6 acom: annotated commands
     7 vc:   verification-conditions
     8 wp:   weakest (liberal) precondition
     9 *)
    10 
    11 VC  =  Hoare +
    12 
    13 datatype  acom = Askip
    14                | Aass   loc aexp
    15                | Asemi  acom acom
    16                | Aif    bexp acom acom
    17                | Awhile bexp assn acom
    18 
    19 consts
    20   vc,wp :: acom => assn => assn
    21   vcwp :: "acom => assn => assn * assn"
    22   astrip :: acom => com
    23 
    24 primrec wp acom
    25   "wp Askip Q = Q"
    26   "wp (Aass x a) Q = (%s.Q(s[a s/x]))"
    27   "wp (Asemi c d) Q = wp c (wp d Q)"
    28   "wp (Aif b c d) Q = (%s. (b s-->wp c Q s) & (~b s-->wp d Q s))" 
    29   "wp (Awhile b I c) Q = I"
    30 
    31 primrec vc acom
    32   "vc Askip Q = (%s.True)"
    33   "vc (Aass x a) Q = (%s.True)"
    34   "vc (Asemi c d) Q = (%s. vc c (wp d Q) s & vc d Q s)"
    35   "vc (Aif b c d) Q = (%s. vc c Q s & vc d Q s)" 
    36   "vc (Awhile b I c) Q = (%s. (I s & ~b s --> Q s) &
    37                               (I s & b s --> wp c I s) & vc c I s)"
    38 
    39 primrec astrip acom
    40   "astrip Askip = SKIP"
    41   "astrip (Aass x a) = (x:=a)"
    42   "astrip (Asemi c d) = (astrip c;astrip d)"
    43   "astrip (Aif b c d) = (IF b THEN astrip c ELSE astrip d)"
    44   "astrip (Awhile b I c) = (WHILE b DO astrip c)"
    45 
    46 (* simultaneous computation of vc and wp: *)
    47 primrec vcwp acom
    48   "vcwp Askip Q = (%s.True, Q)"
    49   "vcwp (Aass x a) Q = (%s.True, %s.Q(s[a s/x]))"
    50   "vcwp (Asemi c d) Q = (let (vcd,wpd) = vcwp d Q;
    51                             (vcc,wpc) = vcwp c wpd
    52                          in (%s. vcc s & vcd s, wpc))"
    53   "vcwp (Aif b c d) Q = (let (vcd,wpd) = vcwp d Q;
    54                             (vcc,wpc) = vcwp c Q
    55                          in (%s. vcc s & vcd s,
    56                              %s.(b s-->wpc s) & (~b s-->wpd s)))"
    57   "vcwp (Awhile b I c) Q = (let (vcc,wpc) = vcwp c I
    58                             in (%s. (I s & ~b s --> Q s) &
    59                                     (I s & b s --> wpc s) & vcc s, I))"
    60 
    61 end