src/HOL/IMP/Procs_Stat_Vars_Stat.thy
author paulson <lp15@cam.ac.uk>
Mon May 23 15:33:24 2016 +0100 (2016-05-23)
changeset 63114 27afe7af7379
parent 53015 a1119cf551e8
permissions -rw-r--r--
Lots of new material for multivariate analysis
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))" |
wenzelm@53015
    20
Seq:     "\<lbrakk> e \<turnstile> (c\<^sub>1,s\<^sub>1) \<Rightarrow> s\<^sub>2;  e \<turnstile> (c\<^sub>2,s\<^sub>2) \<Rightarrow> s\<^sub>3 \<rbrakk> \<Longrightarrow>
wenzelm@53015
    21
          e \<turnstile> (c\<^sub>1;;c\<^sub>2, s\<^sub>1) \<Rightarrow> s\<^sub>3" |
kleing@43158
    22
wenzelm@53015
    23
IfTrue:  "\<lbrakk> bval b (s \<circ> venv e);  e \<turnstile> (c\<^sub>1,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
wenzelm@53015
    24
         e \<turnstile> (IF b THEN c\<^sub>1 ELSE c\<^sub>2, s) \<Rightarrow> t" |
wenzelm@53015
    25
IfFalse: "\<lbrakk> \<not>bval b (s \<circ> venv e);  e \<turnstile> (c\<^sub>2,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
wenzelm@53015
    26
         e \<turnstile> (IF b THEN c\<^sub>1 ELSE c\<^sub>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:
wenzelm@53015
    30
  "\<lbrakk> bval b (s\<^sub>1 \<circ> venv e);  e \<turnstile> (c,s\<^sub>1) \<Rightarrow> s\<^sub>2;
wenzelm@53015
    31
     e \<turnstile> (WHILE b DO c, s\<^sub>2) \<Rightarrow> s\<^sub>3 \<rbrakk> \<Longrightarrow>
wenzelm@53015
    32
   e \<turnstile> (WHILE b DO c, s\<^sub>1) \<Rightarrow> s\<^sub>3" |
kleing@43158
    33
kleing@43158
    34
Var: "(pe,ve(x:=f),f+1) \<turnstile> (c,s) \<Rightarrow> t  \<Longrightarrow>
nipkow@52046
    35
      (pe,ve,f) \<turnstile> ({VAR x; c}, s) \<Rightarrow> t" |
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
nipkow@52046
    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@51019
    48
values "{map t [10,11] |t.
nipkow@51019
    49
  ([], <''x'' := 10, ''y'' := 11>, 12)
nipkow@44923
    50
  \<turnstile> (test_com, <>) \<Rightarrow> t}"
kleing@43158
    51
kleing@43158
    52
end