src/HOL/IMP/Procs_Dyn_Vars_Dyn.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_Dyn_Vars_Dyn imports Procs
kleing@43158
     2
begin
kleing@43158
     3
kleing@43158
     4
subsubsection "Dynamic Scoping of Procedures and Variables"
kleing@43158
     5
nipkow@45212
     6
type_synonym penv = "pname \<Rightarrow> com"
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)" |
wenzelm@53015
    13
Seq:     "\<lbrakk> pe \<turnstile> (c\<^sub>1,s\<^sub>1) \<Rightarrow> s\<^sub>2;  pe \<turnstile> (c\<^sub>2,s\<^sub>2) \<Rightarrow> s\<^sub>3 \<rbrakk> \<Longrightarrow>
wenzelm@53015
    14
          pe \<turnstile> (c\<^sub>1;;c\<^sub>2, s\<^sub>1) \<Rightarrow> s\<^sub>3" |
kleing@43158
    15
wenzelm@53015
    16
IfTrue:  "\<lbrakk> bval b s;  pe \<turnstile> (c\<^sub>1,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
wenzelm@53015
    17
         pe \<turnstile> (IF b THEN c\<^sub>1 ELSE c\<^sub>2, s) \<Rightarrow> t" |
wenzelm@53015
    18
IfFalse: "\<lbrakk> \<not>bval b s;  pe \<turnstile> (c\<^sub>2,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
wenzelm@53015
    19
         pe \<turnstile> (IF b THEN c\<^sub>1 ELSE c\<^sub>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:
wenzelm@53015
    23
  "\<lbrakk> bval b s\<^sub>1;  pe \<turnstile> (c,s\<^sub>1) \<Rightarrow> s\<^sub>2;  pe \<turnstile> (WHILE b DO c, s\<^sub>2) \<Rightarrow> s\<^sub>3 \<rbrakk> \<Longrightarrow>
wenzelm@53015
    24
   pe \<turnstile> (WHILE b DO c, s\<^sub>1) \<Rightarrow> s\<^sub>3" |
kleing@43158
    25
nipkow@52046
    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
Call: "pe \<turnstile> (pe p, s) \<Rightarrow> t  \<Longrightarrow>  pe \<turnstile> (CALL p, s) \<Rightarrow> t" |
kleing@43158
    29
nipkow@52046
    30
Proc: "pe(p := cp) \<turnstile> (c,s) \<Rightarrow> t  \<Longrightarrow>  pe \<turnstile> ({PROC p = cp; c}, s) \<Rightarrow> t"
kleing@43158
    31
kleing@43158
    32
code_pred big_step .
kleing@43158
    33
nipkow@51019
    34
values "{map t [''x'',''y''] |t. (\<lambda>p. SKIP) \<turnstile> (test_com, <>) \<Rightarrow> t}"
kleing@43158
    35
kleing@43158
    36
end