src/HOL/IMP/Procs_Stat_Vars_Stat.thy
author bulwahn
Fri Oct 21 11:17:14 2011 +0200 (2011-10-21)
changeset 45231 d85a2fdc586c
parent 45212 e87feee00a4c
child 47818 151d137f1095
permissions -rw-r--r--
replacing code_inline by code_unfold, removing obsolete code_unfold, code_inline del now that the ancient code generator is removed
kleing@44177
     1
theory Procs_Stat_Vars_Stat imports Procs
kleing@43158
     2
begin
kleing@43158
     3
kleing@43158
     4
subsubsection "Static Scoping of Procedures and Variables"
kleing@43158
     5
kleing@43158
     6
type_synonym addr = nat
nipkow@45212
     7
type_synonym venv = "vname \<Rightarrow> addr"
kleing@43158
     8
type_synonym store = "addr \<Rightarrow> val"
nipkow@45212
     9
type_synonym penv = "(pname \<times> com \<times> venv) list"
kleing@43158
    10
kleing@43158
    11
fun venv :: "penv \<times> venv \<times> nat \<Rightarrow> venv" where
kleing@43158
    12
"venv(_,ve,_) = ve"
kleing@43158
    13
kleing@43158
    14
inductive
kleing@43158
    15
  big_step :: "penv \<times> venv \<times> nat \<Rightarrow> com \<times> store \<Rightarrow> store \<Rightarrow> bool"
kleing@43158
    16
  ("_ \<turnstile> _ \<Rightarrow> _" [60,0,60] 55)
kleing@43158
    17
where
kleing@43158
    18
Skip:    "e \<turnstile> (SKIP,s) \<Rightarrow> s" |
kleing@43158
    19
Assign:  "(pe,ve,f) \<turnstile> (x ::= a,s) \<Rightarrow> s(ve x := aval a (s o ve))" |
kleing@43158
    20
Semi:    "\<lbrakk> e \<turnstile> (c\<^isub>1,s\<^isub>1) \<Rightarrow> s\<^isub>2;  e \<turnstile> (c\<^isub>2,s\<^isub>2) \<Rightarrow> s\<^isub>3 \<rbrakk> \<Longrightarrow>
kleing@43158
    21
          e \<turnstile> (c\<^isub>1;c\<^isub>2, s\<^isub>1) \<Rightarrow> s\<^isub>3" |
kleing@43158
    22
kleing@43158
    23
IfTrue:  "\<lbrakk> bval b (s \<circ> venv e);  e \<turnstile> (c\<^isub>1,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
kleing@43158
    24
         e \<turnstile> (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t" |
kleing@43158
    25
IfFalse: "\<lbrakk> \<not>bval b (s \<circ> venv e);  e \<turnstile> (c\<^isub>2,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
kleing@43158
    26
         e \<turnstile> (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t" |
kleing@43158
    27
kleing@43158
    28
WhileFalse: "\<not>bval b (s \<circ> venv e) \<Longrightarrow> e \<turnstile> (WHILE b DO c,s) \<Rightarrow> s" |
kleing@43158
    29
WhileTrue:
kleing@43158
    30
  "\<lbrakk> bval b (s\<^isub>1 \<circ> venv e);  e \<turnstile> (c,s\<^isub>1) \<Rightarrow> s\<^isub>2;
kleing@43158
    31
     e \<turnstile> (WHILE b DO c, s\<^isub>2) \<Rightarrow> s\<^isub>3 \<rbrakk> \<Longrightarrow>
kleing@43158
    32
   e \<turnstile> (WHILE b DO c, s\<^isub>1) \<Rightarrow> s\<^isub>3" |
kleing@43158
    33
kleing@43158
    34
Var: "(pe,ve(x:=f),f+1) \<turnstile> (c,s) \<Rightarrow> t  \<Longrightarrow>
kleing@43158
    35
      (pe,ve,f) \<turnstile> ({VAR x;; c}, s) \<Rightarrow> t(f := s f)" |
kleing@43158
    36
kleing@43158
    37
Call1: "((p,c,ve)#pe,ve,f) \<turnstile> (c, s) \<Rightarrow> t  \<Longrightarrow>
kleing@43158
    38
        ((p,c,ve)#pe,ve',f) \<turnstile> (CALL p, s) \<Rightarrow> t" |
kleing@43158
    39
Call2: "\<lbrakk> p' \<noteq> p;  (pe,ve,f) \<turnstile> (CALL p, s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
kleing@43158
    40
       ((p',c,ve')#pe,ve,f) \<turnstile> (CALL p, s) \<Rightarrow> t" |
kleing@43158
    41
kleing@43158
    42
Proc: "((p,cp,ve)#pe,ve,f) \<turnstile> (c,s) \<Rightarrow> t
kleing@43158
    43
      \<Longrightarrow>  (pe,ve,f) \<turnstile> ({PROC p = cp;; c}, s) \<Rightarrow> t"
kleing@43158
    44
kleing@43158
    45
code_pred big_step .
kleing@43158
    46
nipkow@44923
    47
nipkow@44923
    48
values "{map t [0,1] |t. ([], <>, 0) \<turnstile> (CALL ''p'', nth [42, 43]) \<Rightarrow> t}"
kleing@43158
    49
nipkow@44923
    50
values "{map t [0, 1, 2] |t.
nipkow@44923
    51
  ([], <''x'' := 0, ''y'' := 1,''z'' := 2>, 0)
nipkow@44923
    52
  \<turnstile> (test_com, <>) \<Rightarrow> t}"
kleing@43158
    53
kleing@43158
    54
end