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