src/HOL/IMP/Procs_Stat_Vars_Dyn.thy
author huffman
Thu Aug 11 09:11:15 2011 -0700 (2011-08-11)
changeset 44165 d26a45f3c835
parent 43158 686fa0a0696e
child 44177 b4b5cbca2519
permissions -rw-r--r--
remove lemma stupid_ext
kleing@43158
     1
theory Procs_Stat_Vars_Dyn imports Util Procs
kleing@43158
     2
begin
kleing@43158
     3
kleing@43158
     4
subsubsection "Static Scoping of Procedures, Dynamic of Variables"
kleing@43158
     5
kleing@43158
     6
type_synonym penv = "(name \<times> com) list"
kleing@43158
     7
kleing@43158
     8
inductive
kleing@43158
     9
  big_step :: "penv \<Rightarrow> com \<times> state \<Rightarrow> state \<Rightarrow> bool" ("_ \<turnstile> _ \<Rightarrow> _" [60,0,60] 55)
kleing@43158
    10
where
kleing@43158
    11
Skip:    "pe \<turnstile> (SKIP,s) \<Rightarrow> s" |
kleing@43158
    12
Assign:  "pe \<turnstile> (x ::= a,s) \<Rightarrow> s(x := aval a s)" |
kleing@43158
    13
Semi:    "\<lbrakk> pe \<turnstile> (c\<^isub>1,s\<^isub>1) \<Rightarrow> s\<^isub>2;  pe \<turnstile> (c\<^isub>2,s\<^isub>2) \<Rightarrow> s\<^isub>3 \<rbrakk> \<Longrightarrow>
kleing@43158
    14
          pe \<turnstile> (c\<^isub>1;c\<^isub>2, s\<^isub>1) \<Rightarrow> s\<^isub>3" |
kleing@43158
    15
kleing@43158
    16
IfTrue:  "\<lbrakk> bval b s;  pe \<turnstile> (c\<^isub>1,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
kleing@43158
    17
         pe \<turnstile> (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t" |
kleing@43158
    18
IfFalse: "\<lbrakk> \<not>bval b s;  pe \<turnstile> (c\<^isub>2,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
kleing@43158
    19
         pe \<turnstile> (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t" |
kleing@43158
    20
kleing@43158
    21
WhileFalse: "\<not>bval b s \<Longrightarrow> pe \<turnstile> (WHILE b DO c,s) \<Rightarrow> s" |
kleing@43158
    22
WhileTrue:
kleing@43158
    23
  "\<lbrakk> bval b s\<^isub>1;  pe \<turnstile> (c,s\<^isub>1) \<Rightarrow> s\<^isub>2;  pe \<turnstile> (WHILE b DO c, s\<^isub>2) \<Rightarrow> s\<^isub>3 \<rbrakk> \<Longrightarrow>
kleing@43158
    24
   pe \<turnstile> (WHILE b DO c, s\<^isub>1) \<Rightarrow> s\<^isub>3" |
kleing@43158
    25
kleing@43158
    26
Var: "pe \<turnstile> (c,s) \<Rightarrow> t  \<Longrightarrow>  pe \<turnstile> ({VAR x;; c}, s) \<Rightarrow> t(x := s x)" |
kleing@43158
    27
kleing@43158
    28
Call1: "(p,c)#pe \<turnstile> (c, s) \<Rightarrow> t  \<Longrightarrow>  (p,c)#pe \<turnstile> (CALL p, s) \<Rightarrow> t" |
kleing@43158
    29
Call2: "\<lbrakk> p' \<noteq> p;  pe \<turnstile> (CALL p, s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
kleing@43158
    30
       (p',c)#pe \<turnstile> (CALL p, s) \<Rightarrow> t" |
kleing@43158
    31
kleing@43158
    32
Proc: "(p,cp)#pe \<turnstile> (c,s) \<Rightarrow> t  \<Longrightarrow>  pe \<turnstile> ({PROC p = cp;; c}, s) \<Rightarrow> t"
kleing@43158
    33
kleing@43158
    34
code_pred big_step .
kleing@43158
    35
kleing@43158
    36
kleing@43158
    37
(* FIXME: example state syntax *)
kleing@43158
    38
values "{map t [''x'', ''y'', ''z''] |t. 
kleing@43158
    39
            [] \<turnstile> (CALL ''p'', (%_. 0)(''x'' := 42, ''y'' := 43)) \<Rightarrow> t}"
kleing@43158
    40
kleing@43158
    41
values "{map t [''x'', ''y'', ''z''] |t. [] \<turnstile> (test_com, (%_. 0) ) \<Rightarrow> t}"
kleing@43158
    42
kleing@43158
    43
end