src/HOL/IMP/C_like.thy
changeset 47818 151d137f1095
parent 45200 1f1897ac7877
child 53015 a1119cf551e8
equal deleted inserted replaced
47817:5d2d63f4363e 47818:151d137f1095
    22 
    22 
    23 datatype
    23 datatype
    24   com = SKIP 
    24   com = SKIP 
    25       | Assign aexp aexp         ("_ ::= _" [61, 61] 61)
    25       | Assign aexp aexp         ("_ ::= _" [61, 61] 61)
    26       | New    aexp aexp
    26       | New    aexp aexp
    27       | Semi   com  com          ("_;/ _"  [60, 61] 60)
    27       | Seq    com  com          ("_;/ _"  [60, 61] 60)
    28       | If     bexp com com     ("(IF _/ THEN _/ ELSE _)"  [0, 0, 61] 61)
    28       | If     bexp com com     ("(IF _/ THEN _/ ELSE _)"  [0, 0, 61] 61)
    29       | While  bexp com         ("(WHILE _/ DO _)"  [0, 61] 61)
    29       | While  bexp com         ("(WHILE _/ DO _)"  [0, 61] 61)
    30 
    30 
    31 inductive
    31 inductive
    32   big_step :: "com \<times> state \<times> nat \<Rightarrow> state \<times> nat \<Rightarrow> bool"  (infix "\<Rightarrow>" 55)
    32   big_step :: "com \<times> state \<times> nat \<Rightarrow> state \<times> nat \<Rightarrow> bool"  (infix "\<Rightarrow>" 55)
    33 where
    33 where
    34 Skip:    "(SKIP,sn) \<Rightarrow> sn" |
    34 Skip:    "(SKIP,sn) \<Rightarrow> sn" |
    35 Assign:  "(lhs ::= a,s,n) \<Rightarrow> (s(aval lhs s := aval a s),n)" |
    35 Assign:  "(lhs ::= a,s,n) \<Rightarrow> (s(aval lhs s := aval a s),n)" |
    36 New:     "(New lhs a,s,n) \<Rightarrow> (s(aval lhs s := n), n+aval a s)"  |
    36 New:     "(New lhs a,s,n) \<Rightarrow> (s(aval lhs s := n), n+aval a s)"  |
    37 Semi:    "\<lbrakk> (c\<^isub>1,sn\<^isub>1) \<Rightarrow> sn\<^isub>2;  (c\<^isub>2,sn\<^isub>2) \<Rightarrow> sn\<^isub>3 \<rbrakk> \<Longrightarrow>
    37 Seq:    "\<lbrakk> (c\<^isub>1,sn\<^isub>1) \<Rightarrow> sn\<^isub>2;  (c\<^isub>2,sn\<^isub>2) \<Rightarrow> sn\<^isub>3 \<rbrakk> \<Longrightarrow>
    38           (c\<^isub>1;c\<^isub>2, sn\<^isub>1) \<Rightarrow> sn\<^isub>3" |
    38           (c\<^isub>1;c\<^isub>2, sn\<^isub>1) \<Rightarrow> sn\<^isub>3" |
    39 
    39 
    40 IfTrue:  "\<lbrakk> bval b s;  (c\<^isub>1,s,n) \<Rightarrow> tn \<rbrakk> \<Longrightarrow>
    40 IfTrue:  "\<lbrakk> bval b s;  (c\<^isub>1,s,n) \<Rightarrow> tn \<rbrakk> \<Longrightarrow>
    41          (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s,n) \<Rightarrow> tn" |
    41          (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s,n) \<Rightarrow> tn" |
    42 IfFalse: "\<lbrakk> \<not>bval b s;  (c\<^isub>2,s,n) \<Rightarrow> tn \<rbrakk> \<Longrightarrow>
    42 IfFalse: "\<lbrakk> \<not>bval b s;  (c\<^isub>2,s,n) \<Rightarrow> tn \<rbrakk> \<Longrightarrow>