IMP/Com.thy
author clasohm
Fri, 19 Jan 1996 12:49:36 +0100
changeset 253 132634d24019
permissions -rw-r--r--
accidentally deleted these files from the repository; now adding them and "cvs rm"ing them again
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
253
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
     1
(*  Title: 	HOL/IMP/Com.thy
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
     2
    ID:         $Id$
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
     3
    Author: 	Heiko Loetzbeyer & Robert Sandner, TUM
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
     4
    Copyright   1994 TUM
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
     5
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
     6
Arithmetic expressions, Boolean expressions, Commands
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
     7
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
     8
And their Operational semantics
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
     9
*)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    10
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    11
Com = Arith +
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    12
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    13
(** Arithmetic expressions **)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    14
types loc
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    15
      state = "loc => nat"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    16
      n2n = "nat => nat"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    17
      n2n2n = "nat => nat => nat"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    18
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    19
arities loc :: term
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    20
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    21
datatype
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    22
  aexp = N (nat)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    23
       | X (loc)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    24
       | Op1 (n2n, aexp)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    25
       | Op2 (n2n2n, aexp, aexp)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    26
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    27
(** Evaluation of arithmetic expressions **)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    28
consts  evala    :: "(aexp*state*nat)set"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    29
       "@evala"  :: "[aexp,state,nat] => bool"	("<_,_>/ -a-> _"  [0,0,50] 50)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    30
translations
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    31
    "<ae,sig> -a-> n" == "<ae,sig,n> : evala"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    32
inductive "evala"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    33
  intrs 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    34
    N   "<N(n),s> -a-> n"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    35
    X  	"<X(x),s> -a-> s(x)"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    36
    Op1 "<e,s> -a-> n ==> <Op1(f,e),s> -a-> f(n)"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    37
    Op2 "[| <e0,s> -a-> n0;  <e1,s>  -a-> n1 |] 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    38
           ==> <Op2(f,e0,e1),s> -a-> f(n0,n1)"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    39
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    40
types n2n2b = "[nat,nat] => bool"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    41
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    42
(** Boolean expressions **)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    43
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    44
datatype
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    45
  bexp = true
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    46
       | false
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    47
       | ROp  (n2n2b, aexp, aexp)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    48
       | noti (bexp)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    49
       | andi (bexp,bexp)	(infixl 60)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    50
       | ori  (bexp,bexp)	(infixl 60)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    51
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    52
(** Evaluation of boolean expressions **)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    53
consts evalb	:: "(bexp*state*bool)set"	
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    54
       "@evalb" :: "[bexp,state,bool] => bool"	("<_,_>/ -b-> _"  [0,0,50] 50)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    55
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    56
translations
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    57
    "<be,sig> -b-> b" == "<be,sig,b> : evalb"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    58
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    59
inductive "evalb"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    60
 intrs (*avoid clash with ML constructors true, false*)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    61
    tru   "<true,s> -b-> True"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    62
    fls   "<false,s> -b-> False"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    63
    ROp   "[| <a0,s> -a-> n0; <a1,s> -a-> n1 |] 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    64
	   ==> <ROp(f,a0,a1),s> -b-> f(n0,n1)"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    65
    noti  "<b,s> -b-> w ==> <noti(b),s> -b-> (~w)"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    66
    andi  "[| <b0,s> -b-> w0; <b1,s> -b-> w1 |] 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    67
          ==> <b0 andi b1,s> -b-> (w0 & w1)"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    68
    ori   "[| <b0,s> -b-> w0; <b1,s> -b-> w1 |] 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    69
	    ==> <b0 ori b1,s> -b-> (w0 | w1)"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    70
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    71
(** Commands **)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    72
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    73
datatype
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    74
  com = skip
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    75
      | ":="   (loc,aexp)	 (infixl  60)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    76
      | semic  (com,com)	 ("_; _"  [60, 60] 10)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    77
      | whileC (bexp,com)	 ("while _ do _"  60)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    78
      | ifC    (bexp, com, com)	 ("ifc _ then _ else _"  60)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    79
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    80
(** Execution of commands **)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    81
consts  evalc    :: "(com*state*state)set"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    82
        "@evalc" :: "[com,state,state] => bool"  ("<_,_>/ -c-> _" [0,0,50] 50)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    83
	"assign" :: "[state,nat,loc] => state"   ("_[_'/_]"       [95,0,0] 95)
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    84
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    85
translations
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    86
       "<ce,sig> -c-> s" == "<ce,sig,s> : evalc"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    87
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    88
rules 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    89
	assign_def	"s[m/x] == (%y. if(y=x,m,s(y)))"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    90
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    91
inductive "evalc"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    92
  intrs
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    93
    skip    "<skip,s> -c-> s"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    94
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    95
    assign  "<a,s> -a-> m ==> <x := a,s> -c-> s[m/x]"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    96
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    97
    semi    "[| <c0,s> -c-> s2; <c1,s2> -c-> s1 |] 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    98
            ==> <c0 ; c1, s> -c-> s1"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
    99
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   100
    ifcTrue "[| <b,s> -b-> True; <c0,s> -c-> s1 |] 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   101
            ==> <ifc b then c0 else c1, s> -c-> s1"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   102
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   103
    ifcFalse "[| <b,s> -b-> False; <c1,s> -c-> s1 |] 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   104
             ==> <ifc b then c0 else c1, s> -c-> s1"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   105
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   106
    whileFalse "<b, s> -b-> False ==> <while b do c,s> -c-> s"
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   107
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   108
    whileTrue  "[| <b,s> -b-> True; <c,s> -c-> s2; 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   109
                  <while b do c, s2> -c-> s1 |] 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   110
               ==> <while b do c, s> -c-> s1 "
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   111
 
132634d24019 accidentally deleted these files from the repository; now adding them and
clasohm
parents:
diff changeset
   112
end