src/HOL/IMP/Denotation.thy
changeset 1696 e84bff5c519b
parent 1481 03f096efa26d
child 2847 6226b83ce2d8
equal deleted inserted replaced
1695:0f9b9eda2a2c 1696:e84bff5c519b
     1 (*  Title:      HOL/IMP/Denotation.thy
     1 (*  Title:      HOL/IMP/Denotation.thy
     2     ID:         $Id$
     2     ID:         $Id$
     3     Author:     Heiko Loetzbeyer & Robert Sandner, TUM
     3     Author:     Heiko Loetzbeyer & Robert Sandner, TUM
     4     Copyright   1994 TUM
     4     Copyright   1994 TUM
     5 
     5 
     6 Denotational semantics of expressions & commands
     6 Denotational semantics of commands
     7 *)
     7 *)
     8 
     8 
     9 Denotation = Com + 
     9 Denotation = Natural + 
    10 
    10 
    11 types com_den = "(state*state)set"
    11 types com_den = "(state*state)set"
       
    12 
       
    13 constdefs
       
    14   Gamma :: [bexp,com_den] => (com_den => com_den)
       
    15            "Gamma b cd == (%phi.{(s,t). (s,t) : (phi O cd) & b(s)} Un 
       
    16                                  {(s,t). (s,t) : id & ~b(s)})"
       
    17     
    12 consts
    18 consts
    13   A     :: aexp => state => nat
       
    14   B     :: bexp => state => bool
       
    15   C     :: com => com_den
    19   C     :: com => com_den
    16   Gamma :: [bexp,com_den] => (com_den => com_den)
       
    17 
       
    18 primrec A aexp
       
    19   A_nat "A(N(n)) = (%s. n)"
       
    20   A_loc "A(X(x)) = (%s. s(x))" 
       
    21   A_op1 "A(Op1 f a) = (%s. f(A a s))"
       
    22   A_op2 "A(Op2 f a0 a1) = (%s. f (A a0 s) (A a1 s))"
       
    23 
       
    24 primrec B bexp
       
    25   B_true  "B(true) = (%s. True)"
       
    26   B_false "B(false) = (%s. False)"
       
    27   B_op    "B(ROp f a0 a1) = (%s. f (A a0 s) (A a1 s))" 
       
    28   B_not   "B(noti(b)) = (%s. ~(B b s))"
       
    29   B_and   "B(b0 andi b1) = (%s. (B b0 s) & (B b1 s))"
       
    30   B_or    "B(b0 ori b1) = (%s. (B b0 s) | (B b1 s))"
       
    31 
       
    32 defs
       
    33   Gamma_def     "Gamma b cd ==   
       
    34                    (%phi.{st. st : (phi O cd) & B b (fst st)} Un 
       
    35                          {st. st : id & ~B b (fst st)})"
       
    36 
    20 
    37 primrec C com
    21 primrec C com
    38   C_skip    "C(Skip) = id"
    22   C_skip    "C(SKIP) = id"
    39   C_assign  "C(x := a) = {st . snd(st) = fst(st)[A a (fst st)/x]}"
    23   C_assign  "C(x := a) = {(s,t). t = s[a(s)/x]}"
    40   C_comp    "C(c0 ; c1) = C(c1) O C(c0)"
    24   C_comp    "C(c0 ; c1) = C(c1) O C(c0)"
    41   C_if      "C(IF b THEN c0 ELSE c1) =   
    25   C_if      "C(IF b THEN c1 ELSE c2) = {(s,t). (s,t) : C(c1) & b(s)} Un
    42                    {st. st:C(c0) & (B b (fst st))} Un 
    26                                        {(s,t). (s,t) : C(c2) & ~ b(s)}"
    43                    {st. st:C(c1) & ~(B b (fst st))}"
       
    44   C_while   "C(WHILE b DO c) = lfp (Gamma b (C c))"
    27   C_while   "C(WHILE b DO c) = lfp (Gamma b (C c))"
    45 
    28 
    46 end
    29 end
       
    30 
       
    31